Changeset 055a68a in mainline for tools/autotool.py


Ignore:
Timestamp:
2015-04-23T23:47:40Z (9 years ago)
Author:
Michal Koutný <xm.koutny+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a18a8b9
Parents:
acb8766e (diff), dcba819 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/autotool.py

    racb8766e r055a68a  
    4848PROBE_OUTPUT = 'probe.s'
    4949
     50PROBE_INT128_SOURCE = 'probe_int128.c'
     51PROBE_INT128_OUTPUT = 'probe_int128.s'
     52
    5053PACKAGE_BINUTILS = "usually part of binutils"
    5154PACKAGE_GCC = "preferably version 4.7.0 or newer"
     
    8588        AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));
    8689
     90extern int main(int, char *[]);
     91
    8792int main(int argc, char *argv[])
    8893{
     
    101106"""
    102107
     108PROBE_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
     119extern int main(int, char *[]);
     120
     121int main(int argc, char *argv[])
     122{
     123"""
     124
     125PROBE_INT128_TAIL = """}
     126"""
     127
    103128def read_config(fname, config):
    104129        "Read HelenOS build configuration"
     
    195220                if (config['CROSS_TARGET'] == "arm32"):
    196221                        gnu_target = "arm-linux-gnueabi"
    197                         clang_target = "arm-unknown-linux"
     222                        clang_target = "arm-unknown-none"
    198223                        helenos_target = "arm-helenos-gnueabi"
    199224               
    200225                if (config['CROSS_TARGET'] == "ia32"):
    201226                        gnu_target = "i686-pc-linux-gnu"
    202                         clang_target = "i386-unknown-linux"
     227                        clang_target = "i686-unknown-none"
    203228                        helenos_target = "i686-pc-helenos"
    204229               
    205230                if (config['CROSS_TARGET'] == "mips32"):
     231                        cc_args.append("-mabi=32")
    206232                        gnu_target = "mipsel-linux-gnu"
    207                         clang_target = "mipsel-unknown-linux"
     233                        clang_target = "mipsel-unknown-none"
    208234                        helenos_target = "mipsel-helenos"
    209                         common['CC_ARGS'].append("-mabi=32")
    210235       
    211236        if (config['PLATFORM'] == "amd64"):
    212237                target = config['PLATFORM']
    213238                gnu_target = "amd64-linux-gnu"
    214                 clang_target = "x86_64-unknown-linux"
     239                clang_target = "x86_64-unknown-none"
    215240                helenos_target = "amd64-helenos"
    216241       
     
    218243                target = config['PLATFORM']
    219244                gnu_target = "arm-linux-gnueabi"
    220                 clang_target = "arm-unknown-linux"
     245                clang_target = "arm-unknown-none-eabi"
    221246                helenos_target = "arm-helenos-gnueabi"
    222247       
     
    224249                target = config['PLATFORM']
    225250                gnu_target = "i686-pc-linux-gnu"
    226                 clang_target = "i386-unknown-linux"
     251                clang_target = "i686-unknown-none"
    227252                helenos_target = "i686-pc-helenos"
    228253       
     
    239264                        target = config['PLATFORM']
    240265                        gnu_target = "mipsel-linux-gnu"
    241                         clang_target = "mipsel-unknown-linux"
     266                        clang_target = "mipsel-unknown-none"
    242267                        helenos_target = "mipsel-helenos"
    243268               
     
    245270                        target = "mips32eb"
    246271                        gnu_target = "mips-linux-gnu"
    247                         clang_target = "mips-unknown-linux"
     272                        clang_target = "mips-unknown-none"
    248273                        helenos_target = "mips-helenos"
    249274       
     
    255280                        target = config['PLATFORM']
    256281                        gnu_target = "mips64el-linux-gnu"
    257                         clang_target = "mips64el-unknown-linux"
     282                        clang_target = "mips64el-unknown-none"
    258283                        helenos_target = "mips64el-helenos"
    259284       
     
    261286                target = config['PLATFORM']
    262287                gnu_target = "ppc-linux-gnu"
    263                 clang_target = "powerpc-unknown-linux"
     288                clang_target = "ppc-unknown-none"
    264289                helenos_target = "ppc-helenos"
    265290       
     
    272297                target = config['PLATFORM']
    273298                gnu_target = "sparc64-linux-gnu"
    274                 clang_target = "sparc-unknown-linux"
     299                clang_target = "sparc-unknown-none"
    275300                helenos_target = "sparc64-helenos"
    276301       
     
    396421       
    397422        for typedef in floatsizes:
    398                 outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
     423                outf.write("\tDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
    399424       
    400425        outf.write(PROBE_TAIL)
     
    510535        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}
    511536
     537def probe_int128(common):
     538        "Generate, compile and parse probing source for 128-bit integers"
     539       
     540        check_common(common, "CC")
     541       
     542        outf = open(PROBE_INT128_SOURCE, 'w')
     543        outf.write(PROBE_INT128_HEAD)
     544        outf.write("\tDECLARE_INTSIZE(\"INT128\", int __attribute((mode(TI))));\n")
     545        outf.write(PROBE_INT128_TAIL)
     546        outf.close()
     547       
     548        args = [common['CC']]
     549        args.extend(common['CC_ARGS'])
     550        args.extend(["-S", "-o", PROBE_INT128_OUTPUT, PROBE_INT128_SOURCE])
     551       
     552        try:
     553                sys.stderr.write("Checking whether the compiler has intrinsic support for 128-bit integers ... ")
     554                output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
     555        except:
     556                sys.stderr.write("no\n")
     557                return False
     558       
     559        if (not os.path.isfile(PROBE_INT128_OUTPUT)):
     560                sys.stderr.write("no\n")
     561                return False
     562       
     563        inf = open(PROBE_INT128_OUTPUT, 'r')
     564        lines = inf.readlines()
     565        inf.close()
     566       
     567        for j in range(len(lines)):
     568                tokens = lines[j].strip().split("\t")
     569               
     570                if (len(tokens) > 0):
     571                        if (tokens[0] == "AUTOTOOL_DECLARE"):
     572                                if (len(tokens) < 7):
     573                                        print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
     574                               
     575                                category = tokens[1]
     576                                subcategory = tokens[2]
     577                                tag = tokens[3]
     578                                name = tokens[4]
     579                                strc = tokens[5]
     580                                conc = tokens[6]
     581                                value = tokens[7]
     582                               
     583                                if (category == "intsize"):
     584                                        try:
     585                                                value_int = decode_value(value)
     586                                        except:
     587                                                print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
     588                                       
     589                                        if (subcategory == "unsigned"):
     590                                                if (value_int != 16):
     591                                                        sys.stderr.write("no\n")
     592                                                        return False
     593                                        elif (subcategory == "signed"):
     594                                                if (value_int != 16):
     595                                                        sys.stderr.write("no\n")
     596                                                        return False
     597                                        else:
     598                                                print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
     599       
     600        sys.stderr.write("yes\n")
     601        return True
     602
    512603def detect_sizes(probe, bytes, inttags, floattags):
    513604        "Detect correct types for fixed-size types"
     
    683774        outmk.close()
    684775
    685 def create_header(hdname, maps):
     776def create_header(hdname, maps, int128):
    686777        "Create header output"
    687778       
     
    703794        for typedef in maps['typedefs']:
    704795                outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype']))
     796       
     797        if (int128):
     798                outhd.write('typedef unsigned int __attribute((mode(TI))) uint128_t;\n')
     799                outhd.write('typedef signed int __attribute((mode(TI))) int128_t;\n')
    705800       
    706801        outhd.write('\n#endif\n')
     
    798893               
    799894                if (config['COMPILER'] == "icc"):
    800                         common['CC'] = "icc"
    801895                        check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental")
    802896                        check_gcc(None, "", common, PACKAGE_GCC)
    803897                        check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
     898                       
     899                        common['CC'] = "icc"
    804900               
    805901                if (config['COMPILER'] == "clang"):
     
    845941                )
    846942               
     943                int128 = probe_int128(common)
     944               
    847945                maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])
    848946               
     
    851949       
    852950        common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
    853 
     951       
    854952        create_makefile(MAKEFILE, common)
    855         create_header(HEADER, maps)
     953        create_header(HEADER, maps, int128)
    856954       
    857955        return 0
Note: See TracChangeset for help on using the changeset viewer.