예제 #1
0
def rules(i):
    rustc_base = join(
        '$rustc $in',
        '--out-dir $b_native',
        '--emit link,dep-info',
        '-L $b_native',
        maybe('-L %s', i.rust_extra_libdir),
        i.rust_lib_externs,
    )

    common_cflags = join(
        '-MMD -MF $out.d',
        '$picflag',
        cond(i.debug, '-ggdb', '-O3'),
    )

    return template(
        '''
        rustflags_debug = -g
        rustflags_release = -g -C opt-level=3
        rustflags_default = %if i.debug% $rustflags_debug %else% $rustflags_release %end%
        # LTO temporarily disabled because it causes LLVM to crash
        # TODO: fix this after upgrading beyond rustc 1.3.0-dev (dc6e3bbb7 2015-07-27)
        #rustflags_lto = %if not i.debug%  -C lto  %end%
        rustflags_lto =

        rule rustc_native_bin
            command = %rustc_base --crate-type=bin $rustflags_lto $rustflags
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_lib
            command = %rustc_base --crate-type=lib $rustflags
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_staticlib
            command = %rustc_base --crate-type=staticlib $rustflags_lto $rustflags
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule c_obj
            command = $cc -c $in -o $out -std=c99 %common_cflags $cflags $user_cflags
            depfile = $out.d
            description = CC $out

        rule cxx_obj
            command = $cxx -c $in -o $out -std=c++14 %common_cflags $cxxflags $user_cxxflags
            depfile = $out.d
            description = CXX $out

        rule link_bin
            command = $cxx $in -o $out $ldflags $user_ldflags $libs
            description = LD $out

        rule link_shlib
            command = $cxx -shared $in -o $out $ldflags $user_ldflags $libs
            description = LD $out
    ''', **locals())
예제 #2
0
def rules(i):
    fastcomp = lambda p: os.path.join(i.emscripten_fastcomp_prefix, 'bin', p) \
            if i.emscripten_fastcomp_prefix is not None else p

    compile_base = join('$rustc $in',
            '--out-dir $b_asmjs',
            '--cfg asmjs',
            '--cfg \'feature="no_std"\'',
            '--target=i686-unknown-linux-gnu',
            '-L $b_asmjs -L $b_native',
            # -C opt-level=3 is mandatory because it eliminates some constructs that cause problems
            # for emscripten-fastcomp.
            '-C opt-level=3',
            '-Z no-landing-pads -C no-stack-check',
            '-C no-vectorize-loops -C no-vectorize-slp')

    return template(r'''
        em_llvm_as = %{fastcomp('llvm-as')}
        em_opt = %{fastcomp('opt')}
        em_llc = %{fastcomp('llc')}


        # See comment in native.py about this sed command
        rule asm_compile_rlib
            command = %compile_base --emit=link,dep-info $
                --crate-type=rlib --crate-name=$crate_name $
                && sed -i -e '\,^$out: ,p;d' $b_asmjs/$crate_name.d
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_compile_ir
            # Like opt-level=3 above, lto is mandatory to prevent emscripten-fastcomp errors.
            command = %compile_base --emit=llvm-ir,dep-info --crate-type=staticlib -C lto $
                && sed -i -e '\,^$out: ,p;d' $b_asmjs/$crate_name.d
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_clean_ir
            command = sed <$in >$out $
                -e '/^target triple/s/i686-unknown-linux-gnu/asmjs-unknown-emscripten/'
            description = ASMJS $out

        rule asm_assemble_bc
            command = $em_llvm_as $in -o $out
            description = ASMJS $out


        rule asm_optimize_bc
            command = $em_opt $in $
                -strip-debug $
                -internalize -internalize-public-api-list="$$(cat $exports_file)" $
                -globaldce $
                -disable-loop-vectorization -disable-slp-vectorization $
                -vectorize-loops=false -vectorize-slp=false $
                -vectorize-slp-aggressive=false $
                -o $out
            description = ASMJS $out

        rule asm_convert_exports
            command = tr '\n' ',' <$in >$out
            description = ASMJS $out

        rule asm_generate_js
            command = $em_llc $in $
                -march=js -filetype=asm $
                -emscripten-assertions=1 $
                -emscripten-no-aliasing-function-pointers $
                -O0 $
                -o $out
            description = ASMJS $out

        rule asm_fill_template
            command = $python3 $root/mk/misc/asmjs_fill_template.py $in >$out
            description = ASMJS $out
    ''', **locals())
예제 #3
0
def rules(i):
    fastcomp = lambda p: os.path.join(i.emscripten_fastcomp_prefix, 'bin', p) \
            if i.emscripten_fastcomp_prefix is not None else p
    passes = lambda p: os.path.join(i.emscripten_passes_prefix, p) \
            if i.emscripten_passes_prefix is not None else p

    compile_base = join(
        '$rustc $in',
        '--out-dir $b_asmjs',
        '--cfg asmjs',
        '--target=i686-unknown-linux-gnu',
        '-L $b_asmjs -L $b_native',
        maybe('-L %s', i.rust_extra_libdir),
        # -C opt-level=3 is mandatory because it eliminates some constructs that cause problems
        # for emscripten-fastcomp.
        '-C opt-level=3',
        '-Z no-landing-pads -C no-stack-check',
        '-C no-vectorize-loops -C no-vectorize-slp')

    return template(
        r'''
        em_llvm_as = %{fastcomp('llvm-as')}
        em_opt = %{fastcomp('opt')}
        em_llc = %{fastcomp('llc')}

        em_pass_remove_overflow_checks = %{passes('RemoveOverflowChecks.so')}
        em_pass_remove_assume = %{passes('RemoveAssume.so')}


        rule asm_compile_rlib
            command = %compile_base --emit=link,dep-info --crate-type=rlib
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_compile_ir
            # Like opt-level=3 above, lto is mandatory to prevent emscripten-fastcomp errors.
            command = %compile_base --emit=llvm-ir,dep-info --crate-type=staticlib -C lto
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_clean_ir
            command = sed <$in >$out $
                -e '/^target triple/s/i686-unknown-linux-gnu/asmjs-unknown-emscripten/'
            description = ASMJS $out

        rule asm_assemble_bc
            command = $em_llvm_as $in -o $out
            description = ASMJS $out


        rule asm_optimize_bc
            command = $em_opt $in $
                -load=$em_pass_remove_overflow_checks $
                -load=$em_pass_remove_assume $
                -strip-debug $
                -internalize -internalize-public-api-list="$$(cat $exports_file)" $
                -remove-overflow-checks $
                -remove-assume $
                -globaldce $
                -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt $
                -enable-emscripten-cxx-exceptions $
                -o $out
            description = ASMJS $out

        rule asm_convert_exports
            command = tr '\n' ',' <$in >$out
            description = ASMJS $out

        rule asm_generate_js
            command = $em_llc $in $
                -march=js -filetype=asm $
                -emscripten-assertions=1 $
                -emscripten-no-aliasing-function-pointers $
                -O3 $
                -o $out
            description = ASMJS $out

        rule asm_add_function_tables
            command = $python3 $root/mk/misc/asmjs_function_tables.py <$in >$out
            description = ASMJS $out

        rule asm_insert_functions
            command = $python3 $root/mk/misc/asmjs_insert_functions.py $in >$out
            description = ASMJS $out
    ''', **locals())
예제 #4
0
def rules(i):
    fastcomp = lambda p: os.path.join(i.emscripten_fastcomp_prefix, 'bin', p) \
            if i.emscripten_fastcomp_prefix is not None else p
    passes = lambda p: os.path.join(i.emscripten_passes_prefix, p) \
            if i.emscripten_passes_prefix is not None else p

    compile_base = join('$rustc $in',
            '--out-dir $b_asmjs',
            '--cfg asmjs',
            '--target=i686-unknown-linux-gnu',
            '-L $b_asmjs -L $b_native',
            maybe('-L %s', i.rust_extra_libdir),
            # -C opt-level=3 is mandatory because it eliminates some constructs that cause problems
            # for emscripten-fastcomp.
            '-C opt-level=3',
            '-Z no-landing-pads -C no-stack-check',
            '-C no-vectorize-loops -C no-vectorize-slp')

    return template(r'''
        em_llvm_as = %{fastcomp('llvm-as')}
        em_opt = %{fastcomp('opt')}
        em_llc = %{fastcomp('llc')}

        em_pass_remove_overflow_checks = %{passes('RemoveOverflowChecks.so')}
        em_pass_remove_assume = %{passes('RemoveAssume.so')}


        rule asm_compile_rlib
            command = %compile_base --emit=link,dep-info --crate-type=rlib
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_compile_ir
            # Like opt-level=3 above, lto is mandatory to prevent emscripten-fastcomp errors.
            command = %compile_base --emit=llvm-ir,dep-info --crate-type=staticlib -C lto
            depfile = $b_asmjs/$crate_name.d
            description = RUSTC $out

        rule asm_clean_ir
            command = sed <$in >$out $
                -e '/^target triple/s/i686-unknown-linux-gnu/asmjs-unknown-emscripten/'
            description = ASMJS $out

        rule asm_assemble_bc
            command = $em_llvm_as $in -o $out
            description = ASMJS $out


        rule asm_optimize_bc
            command = $em_opt $in $
                -load=$em_pass_remove_overflow_checks $
                -load=$em_pass_remove_assume $
                -strip-debug $
                -internalize -internalize-public-api-list="$$(cat $exports_file)" $
                -remove-overflow-checks $
                -remove-assume $
                -globaldce $
                -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt $
                -enable-emscripten-cxx-exceptions $
                -o $out
            description = ASMJS $out

        rule asm_convert_exports
            command = tr '\n' ',' <$in >$out
            description = ASMJS $out

        rule asm_generate_js
            command = $em_llc $in $
                -march=js -filetype=asm $
                -emscripten-assertions=1 $
                -emscripten-no-aliasing-function-pointers $
                -O3 $
                -o $out
            description = ASMJS $out

        rule asm_add_function_tables
            command = $python3 $root/mk/misc/asmjs_function_tables.py <$in >$out
            description = ASMJS $out

        rule asm_insert_functions
            command = $python3 $root/mk/misc/asmjs_insert_functions.py $in >$out
            description = ASMJS $out
    ''', **locals())
예제 #5
0
def rules(i):
    rustc_base = join('$rustc $in',
            '--out-dir $b_native',
            '--emit link,dep-info',
            '-L $b_native',
            maybe('-L %s', i.rust_extra_libdir),
            *('--extern %s' % x for x in i.rust_externs)
            )

    common_cflags = join(
            '-MMD -MF $out.d',
            '$picflag',
            cond(i.debug, '-ggdb', '-O3'),
            )

    return template('''
        rustflags_debug = -g
        rustflags_release = -g -C opt-level=3
        rustflags_default = %if i.debug% $rustflags_debug %else% $rustflags_release %end%
        # LTO temporarily disabled because it causes LLVM to crash
        # TODO: fix this after upgrading beyond rustc 1.3.0-dev (dc6e3bbb7 2015-07-27)
        #rustflags_lto = %if not i.debug%  -C lto  %end%
        rustflags_lto =

        # The `sed` invocations below are hacks to handle nondeterministic
        # depfile line order from rustc.
        # NB: If you remove the sed commands here, also remove the ones in asmjs.py
        rule rustc_native_bin
            command = %rustc_base --crate-name=$crate_name --crate-type=bin $
                $rustflags_lto $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_lib
            command = %rustc_base --crate-name=$crate_name --crate-type=lib $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_dylib
            command = %rustc_base --crate-name=$crate_name --crate-type=dylib $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule rustc_native_staticlib
            command = %rustc_base --crate-name=$crate_name --crate-type=staticlib $
                $rustflags_lto $rustflags $
                && sed -i -e '\\,^$out: ,p;d' $b_native/$crate_name.d
            depfile = $b_native/$crate_name.d
            description = RUSTC $out

        rule c_obj
            command = $cc -c $in -o $out -std=c99 %common_cflags $cflags $user_cflags
            depfile = $out.d
            description = CC $out

        rule cxx_obj
            command = $cxx -c $in -o $out $
                %{i.cxx14_flag} %common_cflags $cxxflags $user_cxxflags
            depfile = $out.d
            description = CXX $out

        rule link_bin
            command = $cxx $in -o $out $ldflags $user_ldflags $libs
            description = LD $out

        rule link_shlib
            command = $cxx -shared $in -o $out $ldflags $user_ldflags $libs
            description = LD $out
    ''', **locals())