Changeset 58775d30 in mainline for tools/autotool.py
- Timestamp:
- 2015-03-16T16:07:21Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2003739
- Parents:
- 6069061 (diff), 795e2bf (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r6069061 r58775d30 48 48 PROBE_OUTPUT = 'probe.s' 49 49 50 PROBE_INT128_SOURCE = 'probe_int128.c' 51 PROBE_INT128_OUTPUT = 'probe_int128.s' 52 50 53 PACKAGE_BINUTILS = "usually part of binutils" 51 54 PACKAGE_GCC = "preferably version 4.7.0 or newer" … … 85 88 AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type)); 86 89 90 extern int main(int, char *[]); 91 87 92 int main(int argc, char *argv[]) 88 93 { … … 101 106 """ 102 107 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 103 128 def read_config(fname, config): 104 129 "Read HelenOS build configuration" … … 195 220 if (config['CROSS_TARGET'] == "arm32"): 196 221 gnu_target = "arm-linux-gnueabi" 197 clang_target = "arm-unknown- linux"222 clang_target = "arm-unknown-none" 198 223 helenos_target = "arm-helenos-gnueabi" 199 224 200 225 if (config['CROSS_TARGET'] == "ia32"): 201 226 gnu_target = "i686-pc-linux-gnu" 202 clang_target = "i 386-unknown-linux"227 clang_target = "i686-unknown-none" 203 228 helenos_target = "i686-pc-helenos" 204 229 205 230 if (config['CROSS_TARGET'] == "mips32"): 231 cc_args.append("-mabi=32") 206 232 gnu_target = "mipsel-linux-gnu" 207 clang_target = "mipsel-unknown- linux"233 clang_target = "mipsel-unknown-none" 208 234 helenos_target = "mipsel-helenos" 209 common['CC_ARGS'].append("-mabi=32")210 235 211 236 if (config['PLATFORM'] == "amd64"): 212 237 target = config['PLATFORM'] 213 238 gnu_target = "amd64-linux-gnu" 214 clang_target = "x86_64-unknown- linux"239 clang_target = "x86_64-unknown-none" 215 240 helenos_target = "amd64-helenos" 216 241 … … 218 243 target = config['PLATFORM'] 219 244 gnu_target = "arm-linux-gnueabi" 220 clang_target = "arm-unknown- linux"245 clang_target = "arm-unknown-none-eabi" 221 246 helenos_target = "arm-helenos-gnueabi" 222 247 … … 224 249 target = config['PLATFORM'] 225 250 gnu_target = "i686-pc-linux-gnu" 226 clang_target = "i 386-unknown-linux"251 clang_target = "i686-unknown-none" 227 252 helenos_target = "i686-pc-helenos" 228 253 … … 239 264 target = config['PLATFORM'] 240 265 gnu_target = "mipsel-linux-gnu" 241 clang_target = "mipsel-unknown- linux"266 clang_target = "mipsel-unknown-none" 242 267 helenos_target = "mipsel-helenos" 243 268 … … 245 270 target = "mips32eb" 246 271 gnu_target = "mips-linux-gnu" 247 clang_target = "mips-unknown- linux"272 clang_target = "mips-unknown-none" 248 273 helenos_target = "mips-helenos" 249 274 … … 255 280 target = config['PLATFORM'] 256 281 gnu_target = "mips64el-linux-gnu" 257 clang_target = "mips64el-unknown- linux"282 clang_target = "mips64el-unknown-none" 258 283 helenos_target = "mips64el-helenos" 259 284 … … 261 286 target = config['PLATFORM'] 262 287 gnu_target = "ppc-linux-gnu" 263 clang_target = "p owerpc-unknown-linux"288 clang_target = "ppc-unknown-none" 264 289 helenos_target = "ppc-helenos" 265 290 … … 272 297 target = config['PLATFORM'] 273 298 gnu_target = "sparc64-linux-gnu" 274 clang_target = "sparc-unknown- linux"299 clang_target = "sparc-unknown-none" 275 300 helenos_target = "sparc64-helenos" 276 301 … … 396 421 397 422 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'])) 399 424 400 425 outf.write(PROBE_TAIL) … … 510 535 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} 511 536 537 def 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 512 603 def detect_sizes(probe, bytes, inttags, floattags): 513 604 "Detect correct types for fixed-size types" … … 683 774 outmk.close() 684 775 685 def create_header(hdname, maps ):776 def create_header(hdname, maps, int128): 686 777 "Create header output" 687 778 … … 703 794 for typedef in maps['typedefs']: 704 795 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') 705 800 706 801 outhd.write('\n#endif\n') … … 798 893 799 894 if (config['COMPILER'] == "icc"): 800 common['CC'] = "icc"801 895 check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental") 802 896 check_gcc(None, "", common, PACKAGE_GCC) 803 897 check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS) 898 899 common['CC'] = "icc" 804 900 805 901 if (config['COMPILER'] == "clang"): … … 845 941 ) 846 942 943 int128 = probe_int128(common) 944 847 945 maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT']) 848 946 … … 851 949 852 950 common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0])) 853 951 854 952 create_makefile(MAKEFILE, common) 855 create_header(HEADER, maps )953 create_header(HEADER, maps, int128) 856 954 857 955 return 0
Note:
See TracChangeset
for help on using the changeset viewer.