Changeset a0a273e in mainline for tools/autotool.py


Ignore:
Timestamp:
2017-10-03T18:12:17Z (7 years ago)
Author:
jzr <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a41cda7
Parents:
0f28387
Message:

Unify compiler handling a bit.

Most compiler flags have been changed from GCC-specific to "common",
since code might build but not work properly without them.
Clang still rejects some of the flags, but at least we can see
the incompatibilities now.

Explicit —target flag was removed from clang, in favor of using clang
through a target-specific symlink. This allows clang to automatically
find correct assembler and linker, if it needs to.

Additionally, assembly language files are now compiled using $(CC)
whether or not they need the preprocessor. This allows clang to build
.s files using its integrated assembler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/autotool.py

    r0f28387 ra0a273e  
    210210        target = None
    211211        gnu_target = None
    212         clang_target = None
    213212        helenos_target = None
    214213        cc_args = []
     
    220219                if (config['CROSS_TARGET'] == "arm32"):
    221220                        gnu_target = "arm-linux-gnueabi"
    222                         clang_target = "arm-unknown-none"
    223221                        helenos_target = "arm-helenos-gnueabi"
    224222               
    225223                if (config['CROSS_TARGET'] == "ia32"):
    226224                        gnu_target = "i686-pc-linux-gnu"
    227                         clang_target = "i686-unknown-none"
    228225                        helenos_target = "i686-pc-helenos"
    229226               
     
    231228                        cc_args.append("-mabi=32")
    232229                        gnu_target = "mipsel-linux-gnu"
    233                         clang_target = "mipsel-unknown-none"
    234230                        helenos_target = "mipsel-helenos"
    235231       
     
    237233                target = config['PLATFORM']
    238234                gnu_target = "amd64-linux-gnu"
    239                 clang_target = "x86_64-unknown-none"
    240235                helenos_target = "amd64-helenos"
    241236       
     
    243238                target = config['PLATFORM']
    244239                gnu_target = "arm-linux-gnueabi"
    245                 clang_target = "arm-unknown-none-eabi"
    246240                helenos_target = "arm-helenos-gnueabi"
    247241       
     
    249243                target = config['PLATFORM']
    250244                gnu_target = "i686-pc-linux-gnu"
    251                 clang_target = "i686-unknown-none"
    252245                helenos_target = "i686-pc-helenos"
    253246       
     
    264257                        target = config['PLATFORM']
    265258                        gnu_target = "mipsel-linux-gnu"
    266                         clang_target = "mipsel-unknown-none"
    267259                        helenos_target = "mipsel-helenos"
    268260               
     
    270262                        target = "mips32eb"
    271263                        gnu_target = "mips-linux-gnu"
    272                         clang_target = "mips-unknown-none"
    273264                        helenos_target = "mips-helenos"
    274265       
     
    280271                        target = config['PLATFORM']
    281272                        gnu_target = "mips64el-linux-gnu"
    282                         clang_target = "mips64el-unknown-none"
    283273                        helenos_target = "mips64el-helenos"
    284274       
     
    286276                target = config['PLATFORM']
    287277                gnu_target = "ppc-linux-gnu"
    288                 clang_target = "ppc-unknown-none"
    289278                helenos_target = "ppc-helenos"
    290279       
     
    292281                target = config['PLATFORM']
    293282                gnu_target = "riscv64-unknown-linux-gnu"
    294                 clang_target = "riscv-unknown-none"
    295283                helenos_target = "riscv64-helenos"
    296284       
     
    298286                target = config['PLATFORM']
    299287                gnu_target = "sparc64-linux-gnu"
    300                 clang_target = "sparc-unknown-none"
    301288                helenos_target = "sparc64-helenos"
    302289       
    303         return (target, cc_args, gnu_target, clang_target, helenos_target)
     290        return (target, cc_args, gnu_target, helenos_target)
    304291
    305292def check_app(args, name, details):
     
    351338        return found
    352339
     340def check_clang(path, prefix, common, details):
     341        "Check for clang"
     342       
     343        common['CLANG'] = "%sclang" % prefix
     344       
     345        if (not path is None):
     346                common['CLANG'] = "%s/%s" % (path, common['CLANG'])
     347       
     348        check_app([common['CLANG'], "--version"], "clang", details)
     349
    353350def check_gcc(path, prefix, common, details):
    354351        "Check for GCC"
     
    427424        outf.close()
    428425       
    429         args = [common['CC']]
    430         args.extend(common['CC_ARGS'])
     426        args = common['CC_AUTOGEN'].split(' ')
    431427        args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
    432428       
     
    547543        outf.close()
    548544       
    549         args = [common['CC']]
    550         args.extend(common['CC_ARGS'])
     545        args = common['CC_AUTOGEN'].split(' ')
    551546        args.extend(["-S", "-o", PROBE_INT128_OUTPUT, PROBE_INT128_SOURCE])
    552547       
     
    852847               
    853848                # Compiler
    854                 common['CC_ARGS'] = []
    855849                if (config['COMPILER'] == "gcc_cross"):
    856                         target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
     850                        target, cc_args, gnu_target, helenos_target = get_target(config)
    857851                       
    858852                        if (target is None) or (gnu_target is None):
     
    867861                       
    868862                        check_common(common, "GCC")
    869                         common['CC'] = common['GCC']
    870                         common['CC_ARGS'].extend(cc_args)
     863                        common['CC'] = " ".join([common['GCC']] + cc_args)
     864                        common['CC_AUTOGEN'] = common['CC']
    871865               
    872866                if (config['COMPILER'] == "gcc_helenos"):
    873                         target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
     867                        target, cc_args, gnu_target, helenos_target = get_target(config)
    874868                       
    875869                        if (target is None) or (helenos_target is None):
     
    884878                       
    885879                        check_common(common, "GCC")
    886                         common['CC'] = common['GCC']
    887                         common['CC_ARGS'].extend(cc_args)
     880                        common['CC'] = " ".join([common['GCC']] + cc_args)
     881                        common['CC_AUTOGEN'] = common['CC']
    888882               
    889883                if (config['COMPILER'] == "gcc_native"):
     
    893887                        check_common(common, "GCC")
    894888                        common['CC'] = common['GCC']
     889                        common['CC_AUTOGEN'] = common['CC']
    895890               
    896891                if (config['COMPILER'] == "icc"):
     
    900895                       
    901896                        common['CC'] = "icc"
     897                        common['CC_AUTOGEN'] = common['CC']
    902898               
    903899                if (config['COMPILER'] == "clang"):
    904                         target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
    905                        
    906                         if (target is None) or (gnu_target is None) or (clang_target is None):
    907                                 print_error(["Unsupported compiler target for clang.",
     900                        target, cc_args, gnu_target, helenos_target = get_target(config)
     901                       
     902                        if (target is None) or (gnu_target is None):
     903                                print_error(["Unsupported compiler target.",
    908904                                             "Please contact the developers of HelenOS."])
    909905                       
     
    911907                        prefix = "%s-" % gnu_target
    912908                       
    913                         check_app(["clang", "--version"], "clang compiler", "preferably version 1.0 or newer")
     909                        check_clang(path, prefix, common, "")
    914910                        check_gcc(path, prefix, common, PACKAGE_GCC)
    915911                        check_binutils(path, prefix, common, PACKAGE_BINUTILS)
    916912                       
    917913                        check_common(common, "GCC")
    918                         common['CC'] = "clang"
    919                         common['CC_ARGS'].extend(cc_args)
    920                         common['CC_ARGS'].append("-target")
    921                         common['CC_ARGS'].append(clang_target)
    922                         common['CLANG_TARGET'] = clang_target
     914                        check_common(common, "CLANG")
     915                        common['CC'] = " ".join([common['CLANG']] + cc_args)
     916                        common['CC_AUTOGEN'] = common['CC'] + " -no-integrated-as"
     917                       
     918                        if (config['INTEGRATED_AS'] == "yes"):
     919                                common['CC'] += " -integrated-as"
     920                       
     921                        if (config['INTEGRATED_AS'] == "no"):
     922                                common['CC'] += " -no-integrated-as"
    923923               
    924924                check_python()
Note: See TracChangeset for help on using the changeset viewer.