Changes in tools/autotool.py [d776329:6db5d4b] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/autotool.py

    rd776329 r6db5d4b  
    4848PROBE_OUTPUT = 'probe.s'
    4949
    50 PROBE_INT128_SOURCE = 'probe_int128.c'
    51 PROBE_INT128_OUTPUT = 'probe_int128.s'
    52 
    5350PACKAGE_BINUTILS = "usually part of binutils"
    5451PACKAGE_GCC = "preferably version 4.7.0 or newer"
     
    8885        AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));
    8986
    90 extern int main(int, char *[]);
    91 
    9287int main(int argc, char *argv[])
    9388{
     
    106101"""
    107102
    108 PROBE_INT128_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
    109         asm volatile ( \\
    110                 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
    111                 : \\
    112                 : [val] "n" (value) \\
    113         )
    114 
    115 #define DECLARE_INTSIZE(tag, type) \\
    116         AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, "", "", sizeof(unsigned type)); \\
    117         AUTOTOOL_DECLARE("intsize", "signed", tag, #type, "", "", sizeof(signed type));
    118 
    119 extern int main(int, char *[]);
    120 
    121 int main(int argc, char *argv[])
    122 {
    123 """
    124 
    125 PROBE_INT128_TAIL = """}
    126 """
    127 
    128103def read_config(fname, config):
    129104        "Read HelenOS build configuration"
     
    211186        gnu_target = None
    212187        clang_target = None
    213         helenos_target = None
    214188        cc_args = []
    215189       
     
    220194                if (config['CROSS_TARGET'] == "arm32"):
    221195                        gnu_target = "arm-linux-gnueabi"
    222                         clang_target = "arm-unknown-none"
    223                         helenos_target = "arm-helenos-gnueabi"
     196                        clang_target = "arm-unknown-linux"
    224197               
    225198                if (config['CROSS_TARGET'] == "ia32"):
    226199                        gnu_target = "i686-pc-linux-gnu"
    227                         clang_target = "i686-unknown-none"
    228                         helenos_target = "i686-pc-helenos"
     200                        clang_target = "i386-unknown-linux"
    229201               
    230202                if (config['CROSS_TARGET'] == "mips32"):
    231                         cc_args.append("-mabi=32")
    232203                        gnu_target = "mipsel-linux-gnu"
    233                         clang_target = "mipsel-unknown-none"
    234                         helenos_target = "mipsel-helenos"
     204                        clang_target = "mipsel-unknown-linux"
     205                        common['CC_ARGS'].append("-mabi=32")
    235206       
    236207        if (config['PLATFORM'] == "amd64"):
    237208                target = config['PLATFORM']
    238209                gnu_target = "amd64-linux-gnu"
    239                 clang_target = "x86_64-unknown-none"
    240                 helenos_target = "amd64-helenos"
     210                clang_target = "x86_64-unknown-linux"
    241211       
    242212        if (config['PLATFORM'] == "arm32"):
    243213                target = config['PLATFORM']
    244214                gnu_target = "arm-linux-gnueabi"
    245                 clang_target = "arm-unknown-none-eabi"
    246                 helenos_target = "arm-helenos-gnueabi"
     215                clang_target = "arm-unknown-linux"
    247216       
    248217        if (config['PLATFORM'] == "ia32"):
    249218                target = config['PLATFORM']
    250219                gnu_target = "i686-pc-linux-gnu"
    251                 clang_target = "i686-unknown-none"
    252                 helenos_target = "i686-pc-helenos"
     220                clang_target = "i386-unknown-linux"
    253221       
    254222        if (config['PLATFORM'] == "ia64"):
    255223                target = config['PLATFORM']
    256224                gnu_target = "ia64-pc-linux-gnu"
    257                 helenos_target = "ia64-pc-helenos"
    258225       
    259226        if (config['PLATFORM'] == "mips32"):
     
    264231                        target = config['PLATFORM']
    265232                        gnu_target = "mipsel-linux-gnu"
    266                         clang_target = "mipsel-unknown-none"
    267                         helenos_target = "mipsel-helenos"
     233                        clang_target = "mipsel-unknown-linux"
    268234               
    269235                if ((config['MACHINE'] == "bmalta")):
    270236                        target = "mips32eb"
    271237                        gnu_target = "mips-linux-gnu"
    272                         clang_target = "mips-unknown-none"
    273                         helenos_target = "mips-helenos"
     238                        clang_target = "mips-unknown-linux"
    274239       
    275240        if (config['PLATFORM'] == "mips64"):
     
    280245                        target = config['PLATFORM']
    281246                        gnu_target = "mips64el-linux-gnu"
    282                         clang_target = "mips64el-unknown-none"
    283                         helenos_target = "mips64el-helenos"
     247                        clang_target = "mips64el-unknown-linux"
    284248       
    285249        if (config['PLATFORM'] == "ppc32"):
    286250                target = config['PLATFORM']
    287251                gnu_target = "ppc-linux-gnu"
    288                 clang_target = "ppc-unknown-none"
    289                 helenos_target = "ppc-helenos"
    290        
    291         if (config['PLATFORM'] == "riscv64"):
    292                 target = config['PLATFORM']
    293                 gnu_target = "riscv64-unknown-linux-gnu"
    294                 clang_target = "riscv-unknown-none"
    295                 helenos_target = "riscv64-helenos"
     252                clang_target = "powerpc-unknown-linux"
    296253       
    297254        if (config['PLATFORM'] == "sparc64"):
    298255                target = config['PLATFORM']
    299256                gnu_target = "sparc64-linux-gnu"
    300                 clang_target = "sparc-unknown-none"
    301                 helenos_target = "sparc64-helenos"
    302        
    303         return (target, cc_args, gnu_target, clang_target, helenos_target)
     257                clang_target = "sparc-unknown-linux"
     258       
     259        return (target, cc_args, gnu_target, clang_target)
    304260
    305261def check_app(args, name, details):
     
    382338        check_app([common['STRIP'], "--version"], "GNU strip", details)
    383339
    384 def check_python():
    385         "Check for Python dependencies"
    386        
    387         try:
    388                 sys.stderr.write("Checking for PyYAML ... ")
    389                 import yaml
    390         except ImportError:
    391                 print_error(["PyYAML is missing.",
    392                              "",
    393                              "Please make sure that it is installed in your",
    394                              "system (usually part of PyYAML package)."])
    395        
    396         sys.stderr.write("ok\n")
    397 
    398340def decode_value(value):
    399341        "Decode integer value"
     
    422364       
    423365        for typedef in floatsizes:
    424                 outf.write("\tDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
     366                outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
    425367       
    426368        outf.write(PROBE_TAIL)
     
    536478        return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'float_tags': float_tags, 'builtin_sizes': builtin_sizes, 'builtin_signs': builtin_signs}
    537479
    538 def probe_int128(common):
    539         "Generate, compile and parse probing source for 128-bit integers"
    540        
    541         check_common(common, "CC")
    542        
    543         outf = open(PROBE_INT128_SOURCE, 'w')
    544         outf.write(PROBE_INT128_HEAD)
    545         outf.write("\tDECLARE_INTSIZE(\"INT128\", int __attribute((mode(TI))));\n")
    546         outf.write(PROBE_INT128_TAIL)
    547         outf.close()
    548        
    549         args = [common['CC']]
    550         args.extend(common['CC_ARGS'])
    551         args.extend(["-S", "-o", PROBE_INT128_OUTPUT, PROBE_INT128_SOURCE])
    552        
    553         try:
    554                 sys.stderr.write("Checking whether the compiler has intrinsic support for 128-bit integers ... ")
    555                 output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
    556         except:
    557                 sys.stderr.write("no\n")
    558                 return False
    559        
    560         if (not os.path.isfile(PROBE_INT128_OUTPUT)):
    561                 sys.stderr.write("no\n")
    562                 return False
    563        
    564         inf = open(PROBE_INT128_OUTPUT, 'r')
    565         lines = inf.readlines()
    566         inf.close()
    567        
    568         for j in range(len(lines)):
    569                 tokens = lines[j].strip().split("\t")
    570                
    571                 if (len(tokens) > 0):
    572                         if (tokens[0] == "AUTOTOOL_DECLARE"):
    573                                 if (len(tokens) < 7):
    574                                         print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
    575                                
    576                                 category = tokens[1]
    577                                 subcategory = tokens[2]
    578                                 tag = tokens[3]
    579                                 name = tokens[4]
    580                                 strc = tokens[5]
    581                                 conc = tokens[6]
    582                                 value = tokens[7]
    583                                
    584                                 if (category == "intsize"):
    585                                         try:
    586                                                 value_int = decode_value(value)
    587                                         except:
    588                                                 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
    589                                        
    590                                         if (subcategory == "unsigned"):
    591                                                 if (value_int != 16):
    592                                                         sys.stderr.write("no\n")
    593                                                         return False
    594                                         elif (subcategory == "signed"):
    595                                                 if (value_int != 16):
    596                                                         sys.stderr.write("no\n")
    597                                                         return False
    598                                         else:
    599                                                 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
    600        
    601         sys.stderr.write("yes\n")
    602         return True
    603 
    604480def detect_sizes(probe, bytes, inttags, floattags):
    605481        "Detect correct types for fixed-size types"
     
    775651        outmk.close()
    776652
    777 def create_header(hdname, maps, int128):
     653def create_header(hdname, maps):
    778654        "Create header output"
    779655       
     
    795671        for typedef in maps['typedefs']:
    796672                outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype']))
    797        
    798         if (int128):
    799                 outhd.write('typedef unsigned int __attribute((mode(TI))) uint128_t;\n')
    800                 outhd.write('typedef signed int __attribute((mode(TI))) int128_t;\n')
    801673       
    802674        outhd.write('\n#endif\n')
     
    824696        else:
    825697                cross_prefix = "/usr/local/cross"
    826        
    827         # HelenOS cross-compiler prefix
    828         if ('CROSS_HELENOS_PREFIX' in os.environ):
    829                 cross_helenos_prefix = os.environ['CROSS_HELENOS_PREFIX']
    830         else:
    831                 cross_helenos_prefix = "/usr/local/cross-helenos"
    832698       
    833699        # Prefix binutils tools on Solaris
     
    853719                common['CC_ARGS'] = []
    854720                if (config['COMPILER'] == "gcc_cross"):
    855                         target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
     721                        target, cc_args, gnu_target, clang_target = get_target(config)
    856722                       
    857723                        if (target is None) or (gnu_target is None):
     
    869735                        common['CC_ARGS'].extend(cc_args)
    870736               
    871                 if (config['COMPILER'] == "gcc_helenos"):
    872                         target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
    873                        
    874                         if (target is None) or (helenos_target is None):
    875                                 print_error(["Unsupported compiler target for GNU GCC.",
    876                                              "Please contact the developers of HelenOS."])
    877                        
    878                         path = "%s/%s/bin" % (cross_helenos_prefix, target)
    879                         prefix = "%s-" % helenos_target
    880                        
    881                         check_gcc(path, prefix, common, PACKAGE_CROSS)
    882                         check_binutils(path, prefix, common, PACKAGE_CROSS)
    883                        
    884                         check_common(common, "GCC")
    885                         common['CC'] = common['GCC']
    886                         common['CC_ARGS'].extend(cc_args)
    887                
    888737                if (config['COMPILER'] == "gcc_native"):
    889738                        check_gcc(None, "", common, PACKAGE_GCC)
     
    894743               
    895744                if (config['COMPILER'] == "icc"):
     745                        common['CC'] = "icc"
    896746                        check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental")
    897747                        check_gcc(None, "", common, PACKAGE_GCC)
    898748                        check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
    899                        
    900                         common['CC'] = "icc"
    901749               
    902750                if (config['COMPILER'] == "clang"):
    903                         target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)
     751                        target, cc_args, gnu_target, clang_target = get_target(config)
    904752                       
    905753                        if (target is None) or (gnu_target is None) or (clang_target is None):
     
    921769                        common['CLANG_TARGET'] = clang_target
    922770               
    923                 check_python()
    924                
    925771                # Platform-specific utilities
    926772                if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")):
    927                         common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage", "xorriso"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage")
    928                         if common['GENISOIMAGE'] == 'xorriso':
    929                                 common['GENISOIMAGE'] += ' -as genisoimage'
     773                        common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage")
    930774               
    931775                probe = probe_compiler(common,
     
    944788                )
    945789               
    946                 int128 = probe_int128(common)
    947                
    948790                maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])
    949791               
     
    951793                sandbox_leave(owd)
    952794       
    953         common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
    954        
    955795        create_makefile(MAKEFILE, common)
    956         create_header(HEADER, maps, int128)
     796        create_header(HEADER, maps)
    957797       
    958798        return 0
Note: See TracChangeset for help on using the changeset viewer.