Changeset 32355bc in mainline


Ignore:
Timestamp:
2019-08-17T12:49:42Z (5 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5fd05862
Parents:
fa70134
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-15 12:58:56)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-08-17 12:49:42)
Message:

Remove the generated common.h header

We haven't used it in some time, instead relying on the compiler
providing types with properties we want. Since we only support
building with GCC and Clang, extra detection code is just dead weight.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rfa70134 r32355bc  
    4141
    4242COMMON_MAKEFILE = Makefile.common
    43 COMMON_HEADER = common.h
    4443
    4544CONFIG_MAKEFILE = Makefile.config
     
    5352        $(MAKE) -r -C boot PRECHECK=$(PRECHECK)
    5453
    55 common: $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(ERRNO_HEADER)
     54common: $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(ERRNO_HEADER)
    5655
    5756kernel: common
     
    123122# Autotool (detects compiler features)
    124123
    125 autotool $(COMMON_MAKEFILE) $(COMMON_HEADER): $(CONFIG_MAKEFILE) $(AUTOTOOL)
     124autotool $(COMMON_MAKEFILE): $(CONFIG_MAKEFILE) $(AUTOTOOL)
    126125        $(AUTOTOOL)
    127         diff -q $(COMMON_HEADER).new $(COMMON_HEADER) 2> /dev/null; if [ $$? -ne 0 ]; then mv -f $(COMMON_HEADER).new $(COMMON_HEADER); fi
    128126
    129127# Build-time configuration
     
    153151
    154152distclean: clean
    155         rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-*
     153        rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-*
    156154
    157155clean:
  • boot/Makefile

    rfa70134 r32355bc  
    3131include Makefile.common
    3232
    33 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(PREBUILD) build_dist
     33all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(PREBUILD) build_dist
    3434        $(MAKE) -r -f $(BUILD) PRECHECK=$(PRECHECK)
    3535ifneq ($(POSTBUILD),)
  • boot/Makefile.build

    rfa70134 r32355bc  
    7373endif
    7474
    75 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
     75all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
    7676
    7777clean:
  • boot/Makefile.common

    rfa70134 r32355bc  
    3535
    3636COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
    37 COMMON_HEADER = $(ROOT_PATH)/common.h
    3837
    3938CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
  • kernel/Makefile

    rfa70134 r32355bc  
    3535
    3636COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
    37 COMMON_HEADER = $(ROOT_PATH)/common.h
    3837COMMON_HEADER_ARCH = arch/$(KARCH)/include/arch/common.h
    3938
     
    7473.DELETE_ON_ERROR:
    7574
    76 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(KERNEL) $(DISASM)
     75all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(KERNEL) $(DISASM)
    7776
    7877clean: autogen_clean
  • tools/autotool.py

    rfa70134 r32355bc  
    4242CONFIG = 'Makefile.config'
    4343MAKEFILE = 'Makefile.common'
    44 HEADER = 'common.h.new'
    45 GUARD = '_AUTOTOOL_COMMON_H_'
    46 
    47 PROBE_SOURCE = 'probe.c'
    48 PROBE_OUTPUT = 'probe.s'
    49 
    50 PACKAGE_BINUTILS = "usually part of binutils"
    51 PACKAGE_GCC = "preferably version 4.7.0 or newer"
     44
    5245PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
    5346PACKAGE_CLANG = "reasonably recent version of clang needs to be installed"
    54 
    55 TOOLCHAIN_FAIL = [
    56         "Compiler toolchain for target is not installed, or CROSS_PREFIX",
    57         "environment variable is not set correctly. Use tools/toolchain.sh",
    58         "to (re)build the cross-compiler toolchain."]
    59 COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."
    60 COMPILER_WARNING = "The compilation of HelenOS might fail."
    61 
    62 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, tag, name, signedness, base, size, compatible) \\
    63         asm volatile ( \\
    64                 "AUTOTOOL_DECLARE\\t" category "\\t" tag "\\t" name "\\t" signedness "\\t" base "\\t%[size_val]\\t%[cmp_val]\\n" \\
    65                 : \\
    66                 : [size_val] "n" (size), [cmp_val] "n" (compatible) \\
    67         )
    68 
    69 #define STRING(arg)      STRING_ARG(arg)
    70 #define STRING_ARG(arg)  #arg
    71 
    72 #define DECLARE_BUILTIN_TYPE(tag, type) \\
    73         AUTOTOOL_DECLARE("unsigned long long int", tag, STRING(type), "unsigned", "long long", sizeof(type), __builtin_types_compatible_p(type, unsigned long long int)); \\
    74         AUTOTOOL_DECLARE("unsigned long int", tag, STRING(type), "unsigned", "long", sizeof(type), __builtin_types_compatible_p(type, unsigned long int)); \\
    75         AUTOTOOL_DECLARE("unsigned int", tag, STRING(type), "unsigned", "int", sizeof(type), __builtin_types_compatible_p(type, unsigned int)); \\
    76         AUTOTOOL_DECLARE("unsigned short int", tag, STRING(type), "unsigned", "short", sizeof(type), __builtin_types_compatible_p(type, unsigned short int)); \\
    77         AUTOTOOL_DECLARE("unsigned char", tag, STRING(type), "unsigned", "char", sizeof(type), __builtin_types_compatible_p(type, unsigned char)); \\
    78         AUTOTOOL_DECLARE("signed long long int", tag, STRING(type), "signed", "long long", sizeof(type), __builtin_types_compatible_p(type, signed long long int)); \\
    79         AUTOTOOL_DECLARE("signed long int", tag, STRING(type), "signed", "long", sizeof(type), __builtin_types_compatible_p(type, signed long int)); \\
    80         AUTOTOOL_DECLARE("signed int", tag, STRING(type), "signed", "int", sizeof(type), __builtin_types_compatible_p(type, signed int)); \\
    81         AUTOTOOL_DECLARE("signed short int", tag, STRING(type), "signed", "short", sizeof(type), __builtin_types_compatible_p(type, signed short int)); \\
    82         AUTOTOOL_DECLARE("signed char", tag, STRING(type), "signed", "char", sizeof(type), __builtin_types_compatible_p(type, signed char)); \\
    83         AUTOTOOL_DECLARE("pointer", tag, STRING(type), "N/A", "pointer", sizeof(type), __builtin_types_compatible_p(type, void*)); \\
    84         AUTOTOOL_DECLARE("long double", tag, STRING(type), "signed", "long double", sizeof(type), __builtin_types_compatible_p(type, long double)); \\
    85         AUTOTOOL_DECLARE("double", tag, STRING(type), "signed", "double", sizeof(type), __builtin_types_compatible_p(type, double)); \\
    86         AUTOTOOL_DECLARE("float", tag, STRING(type), "signed", "float", sizeof(type), __builtin_types_compatible_p(type, float));
    87 
    88 extern int main(int, char *[]);
    89 
    90 int main(int argc, char *argv[])
    91 {
    92 """
    93 
    94 PROBE_TAIL = """}
    95 """
    9647
    9748def read_config(fname, config):
     
    11970
    12071        sys.exit(1)
    121 
    122 def print_warning(msg):
    123         "Print a bold error message"
    124 
    125         sys.stderr.write("\n")
    126         sys.stderr.write("######################################################################\n")
    127         sys.stderr.write("HelenOS build sanity check warning:\n")
    128         sys.stderr.write("\n")
    129         sys.stderr.write("%s\n" % "\n".join(msg))
    130         sys.stderr.write("######################################################################\n")
    131         sys.stderr.write("\n")
    132 
    133         time.sleep(5)
    13472
    13573def sandbox_enter():
     
    371309        check_app([common['STRIP'], "--version"], "GNU strip", details)
    372310
    373 def decode_value(value):
    374         "Decode integer value"
    375 
    376         base = 10
    377 
    378         if ((value.startswith('$')) or (value.startswith('#'))):
    379                 value = value[1:]
    380 
    381         if (value.startswith('0x')):
    382                 value = value[2:]
    383                 base = 16
    384 
    385         return int(value, base)
    386 
    387 def probe_compiler(cc, common, typesizes):
    388         "Generate, compile and parse probing source"
    389 
    390         check_common(common, "CC")
    391 
    392         outf = open(PROBE_SOURCE, 'w')
    393         outf.write(PROBE_HEAD)
    394 
    395         for typedef in typesizes:
    396                 if 'def' in typedef:
    397                         outf.write("#ifdef %s\n" % typedef['def'])
    398                 outf.write("\tDECLARE_BUILTIN_TYPE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
    399                 if 'def' in typedef:
    400                         outf.write("#endif\n")
    401 
    402         outf.write(PROBE_TAIL)
    403         outf.close()
    404 
    405         args = cc.split(' ')
    406         args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
    407 
    408         try:
    409                 sys.stderr.write("Checking compiler properties ... ")
    410                 output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
    411         except:
    412                 sys.stderr.write("failed\n")
    413                 print_error(["Error executing \"%s\"." % " ".join(args),
    414                              "Make sure that the compiler works properly."])
    415 
    416         if (not os.path.isfile(PROBE_OUTPUT)):
    417                 sys.stderr.write("failed\n")
    418                 print(output[1])
    419                 print_error(["Error executing \"%s\"." % " ".join(args),
    420                              "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,
    421                              "",
    422                              output[0],
    423                              output[1]])
    424 
    425         sys.stderr.write("ok\n")
    426 
    427         inf = open(PROBE_OUTPUT, 'r')
    428         lines = inf.readlines()
    429         inf.close()
    430 
    431         builtins = {}
    432 
    433         for j in range(len(lines)):
    434                 tokens = lines[j].strip().split("\t")
    435 
    436                 if (len(tokens) > 0):
    437                         if (tokens[0] == "AUTOTOOL_DECLARE"):
    438                                 if (len(tokens) < 8):
    439                                         print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
    440 
    441                                 category = tokens[1]
    442                                 tag = tokens[2]
    443                                 name = tokens[3]
    444                                 signedness = tokens[4]
    445                                 base = tokens[5]
    446                                 size = tokens[6]
    447                                 compatible = tokens[7]
    448 
    449                                 try:
    450                                         compatible_int = decode_value(compatible)
    451                                         size_int = decode_value(size)
    452                                 except:
    453                                         print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
    454 
    455                                 if (compatible_int == 1):
    456                                         builtins[tag] = {
    457                                                 'tag': tag,
    458                                                 'name': name,
    459                                                 'sign': signedness,
    460                                                 'base': base,
    461                                                 'size': size_int,
    462                                         }
    463 
    464         for typedef in typesizes:
    465                 if not typedef['tag'] in builtins:
    466                         print_error(['Unable to determine the properties of type %s.' % typedef['tag'],
    467                              COMPILER_FAIL])
    468                 if 'sname' in typedef:
    469                         builtins[typedef['tag']]['sname'] = typedef['sname']
    470 
    471         return builtins
    472 
    473 def get_suffix(type):
    474         if type['sign'] == 'unsigned':
    475                 return {
    476                         "char": "",
    477                         "short": "",
    478                         "int": "U",
    479                         "long": "UL",
    480                         "long long": "ULL",
    481                 }[type['base']]
    482         else:
    483                 return {
    484                         "char": "",
    485                         "short": "",
    486                         "int": "",
    487                         "long": "L",
    488                         "long long": "LL",
    489                 }[type['base']]
    490 
    491 def get_max(type):
    492         val = (1 << (type['size']*8 - 1))
    493         if type['sign'] == 'unsigned':
    494                 val *= 2
    495         return val - 1
    496 
    497 def detect_sizes(probe):
    498         "Detect properties of builtin types"
    499 
    500         macros = {}
    501 
    502         for type in probe.values():
    503                 macros['__SIZEOF_%s__' % type['tag']] = type['size']
    504 
    505                 if ('sname' in type):
    506                         macros['__%s_TYPE__'  % type['sname']] = type['name']
    507                         macros['__%s_WIDTH__' % type['sname']] = type['size']*8
    508                         macros['__%s_%s__' % (type['sname'], type['sign'].upper())] = "1"
    509                         macros['__%s_C_SUFFIX__' % type['sname']] = get_suffix(type)
    510                         macros['__%s_MAX__' % type['sname']] = "%d%s" % (get_max(type), get_suffix(type))
    511 
    512         if (probe['SIZE_T']['sign'] != 'unsigned'):
    513                 print_error(['The type size_t is not unsigned.', COMPILER_FAIL])
    514 
    515         return macros
    516 
    517311def create_makefile(mkname, common):
    518312        "Create makefile output"
     
    647441                                common['GENISOIMAGE'] += ' -as genisoimage'
    648442
    649                 probe = probe_compiler(cc_autogen, common,
    650                         [
    651                                 {'type': 'long long int', 'tag': 'LONG_LONG', 'sname': 'LLONG' },
    652                                 {'type': 'long int', 'tag': 'LONG', 'sname': 'LONG' },
    653                                 {'type': 'int', 'tag': 'INT', 'sname': 'INT' },
    654                                 {'type': 'short int', 'tag': 'SHORT', 'sname': 'SHRT'},
    655                                 {'type': 'void*', 'tag': 'POINTER'},
    656                                 {'type': 'long double', 'tag': 'LONG_DOUBLE'},
    657                                 {'type': 'double', 'tag': 'DOUBLE'},
    658                                 {'type': 'float', 'tag': 'FLOAT'},
    659                                 {'type': '__SIZE_TYPE__', 'tag': 'SIZE_T', 'def': '__SIZE_TYPE__', 'sname': 'SIZE' },
    660                                 {'type': '__PTRDIFF_TYPE__', 'tag': 'PTRDIFF_T', 'def': '__PTRDIFF_TYPE__', 'sname': 'PTRDIFF' },
    661                                 {'type': '__WINT_TYPE__', 'tag': 'WINT_T', 'def': '__WINT_TYPE__', 'sname': 'WINT' },
    662                                 {'type': '__WCHAR_TYPE__', 'tag': 'WCHAR_T', 'def': '__WCHAR_TYPE__', 'sname': 'WCHAR' },
    663                                 {'type': '__INTMAX_TYPE__', 'tag': 'INTMAX_T', 'def': '__INTMAX_TYPE__', 'sname': 'INTMAX' },
    664                                 {'type': 'unsigned __INTMAX_TYPE__', 'tag': 'UINTMAX_T', 'def': '__INTMAX_TYPE__', 'sname': 'UINTMAX' },
    665                         ]
    666                 )
    667 
    668                 macros = detect_sizes(probe)
    669 
    670443        finally:
    671444                sandbox_leave(owd)
    672445
    673446        create_makefile(MAKEFILE, common)
    674         create_header(HEADER, macros)
    675447
    676448        return 0
  • uspace/Makefile.common

    rfa70134 r32355bc  
    6060
    6161COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
    62 COMMON_HEADER = $(ROOT_PATH)/common.h
    6362
    6463CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
Note: See TracChangeset for help on using the changeset viewer.