Changes in tools/autotool.py [6db5d4b:d776329] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r6db5d4b rd776329 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" … … 186 211 gnu_target = None 187 212 clang_target = None 213 helenos_target = None 188 214 cc_args = [] 189 215 … … 194 220 if (config['CROSS_TARGET'] == "arm32"): 195 221 gnu_target = "arm-linux-gnueabi" 196 clang_target = "arm-unknown-linux" 222 clang_target = "arm-unknown-none" 223 helenos_target = "arm-helenos-gnueabi" 197 224 198 225 if (config['CROSS_TARGET'] == "ia32"): 199 226 gnu_target = "i686-pc-linux-gnu" 200 clang_target = "i386-unknown-linux" 227 clang_target = "i686-unknown-none" 228 helenos_target = "i686-pc-helenos" 201 229 202 230 if (config['CROSS_TARGET'] == "mips32"): 231 cc_args.append("-mabi=32") 203 232 gnu_target = "mipsel-linux-gnu" 204 clang_target = "mipsel-unknown- linux"205 common['CC_ARGS'].append("-mabi=32")233 clang_target = "mipsel-unknown-none" 234 helenos_target = "mipsel-helenos" 206 235 207 236 if (config['PLATFORM'] == "amd64"): 208 237 target = config['PLATFORM'] 209 238 gnu_target = "amd64-linux-gnu" 210 clang_target = "x86_64-unknown-linux" 239 clang_target = "x86_64-unknown-none" 240 helenos_target = "amd64-helenos" 211 241 212 242 if (config['PLATFORM'] == "arm32"): 213 243 target = config['PLATFORM'] 214 244 gnu_target = "arm-linux-gnueabi" 215 clang_target = "arm-unknown-linux" 245 clang_target = "arm-unknown-none-eabi" 246 helenos_target = "arm-helenos-gnueabi" 216 247 217 248 if (config['PLATFORM'] == "ia32"): 218 249 target = config['PLATFORM'] 219 250 gnu_target = "i686-pc-linux-gnu" 220 clang_target = "i386-unknown-linux" 251 clang_target = "i686-unknown-none" 252 helenos_target = "i686-pc-helenos" 221 253 222 254 if (config['PLATFORM'] == "ia64"): 223 255 target = config['PLATFORM'] 224 256 gnu_target = "ia64-pc-linux-gnu" 257 helenos_target = "ia64-pc-helenos" 225 258 226 259 if (config['PLATFORM'] == "mips32"): … … 231 264 target = config['PLATFORM'] 232 265 gnu_target = "mipsel-linux-gnu" 233 clang_target = "mipsel-unknown-linux" 266 clang_target = "mipsel-unknown-none" 267 helenos_target = "mipsel-helenos" 234 268 235 269 if ((config['MACHINE'] == "bmalta")): 236 270 target = "mips32eb" 237 271 gnu_target = "mips-linux-gnu" 238 clang_target = "mips-unknown-linux" 272 clang_target = "mips-unknown-none" 273 helenos_target = "mips-helenos" 239 274 240 275 if (config['PLATFORM'] == "mips64"): … … 245 280 target = config['PLATFORM'] 246 281 gnu_target = "mips64el-linux-gnu" 247 clang_target = "mips64el-unknown-linux" 282 clang_target = "mips64el-unknown-none" 283 helenos_target = "mips64el-helenos" 248 284 249 285 if (config['PLATFORM'] == "ppc32"): 250 286 target = config['PLATFORM'] 251 287 gnu_target = "ppc-linux-gnu" 252 clang_target = "powerpc-unknown-linux" 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" 253 296 254 297 if (config['PLATFORM'] == "sparc64"): 255 298 target = config['PLATFORM'] 256 299 gnu_target = "sparc64-linux-gnu" 257 clang_target = "sparc-unknown-linux" 258 259 return (target, cc_args, gnu_target, clang_target) 300 clang_target = "sparc-unknown-none" 301 helenos_target = "sparc64-helenos" 302 303 return (target, cc_args, gnu_target, clang_target, helenos_target) 260 304 261 305 def check_app(args, name, details): … … 338 382 check_app([common['STRIP'], "--version"], "GNU strip", details) 339 383 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 340 398 def decode_value(value): 341 399 "Decode integer value" … … 364 422 365 423 for typedef in floatsizes: 366 outf.write("\ nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))424 outf.write("\tDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type'])) 367 425 368 426 outf.write(PROBE_TAIL) … … 478 536 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} 479 537 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 480 604 def detect_sizes(probe, bytes, inttags, floattags): 481 605 "Detect correct types for fixed-size types" … … 651 775 outmk.close() 652 776 653 def create_header(hdname, maps ):777 def create_header(hdname, maps, int128): 654 778 "Create header output" 655 779 … … 671 795 for typedef in maps['typedefs']: 672 796 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') 673 801 674 802 outhd.write('\n#endif\n') … … 696 824 else: 697 825 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" 698 832 699 833 # Prefix binutils tools on Solaris … … 719 853 common['CC_ARGS'] = [] 720 854 if (config['COMPILER'] == "gcc_cross"): 721 target, cc_args, gnu_target, clang_target = get_target(config)855 target, cc_args, gnu_target, clang_target, helenos_target = get_target(config) 722 856 723 857 if (target is None) or (gnu_target is None): … … 735 869 common['CC_ARGS'].extend(cc_args) 736 870 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 737 888 if (config['COMPILER'] == "gcc_native"): 738 889 check_gcc(None, "", common, PACKAGE_GCC) … … 743 894 744 895 if (config['COMPILER'] == "icc"): 745 common['CC'] = "icc"746 896 check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental") 747 897 check_gcc(None, "", common, PACKAGE_GCC) 748 898 check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS) 899 900 common['CC'] = "icc" 749 901 750 902 if (config['COMPILER'] == "clang"): 751 target, cc_args, gnu_target, clang_target = get_target(config)903 target, cc_args, gnu_target, clang_target, helenos_target = get_target(config) 752 904 753 905 if (target is None) or (gnu_target is None) or (clang_target is None): … … 769 921 common['CLANG_TARGET'] = clang_target 770 922 923 check_python() 924 771 925 # Platform-specific utilities 772 926 if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")): 773 common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage") 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' 774 930 775 931 probe = probe_compiler(common, … … 788 944 ) 789 945 946 int128 = probe_int128(common) 947 790 948 maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT']) 791 949 … … 793 951 sandbox_leave(owd) 794 952 953 common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0])) 954 795 955 create_makefile(MAKEFILE, common) 796 create_header(HEADER, maps )956 create_header(HEADER, maps, int128) 797 957 798 958 return 0
Note:
See TracChangeset
for help on using the changeset viewer.