Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset a0a273e in mainline for boot/Makefile.build


Ignore:
Timestamp:
2017-10-03T18:12:17Z (4 years ago)
Author:
jzr <zarevucky.jiri@…>
Branches:
lfn, master
Children:
a41cda7
Parents:
0f28387
Message:

Unify compiler handling a bit.

Most compiler flags have been changed from GCC-specific to "common",
since code might build but not work properly without them.
Clang still rejects some of the flags, but at least we can see
the incompatibilities now.

Explicit —target flag was removed from clang, in favor of using clang
through a target-specific symlink. This allows clang to automatically
find correct assembler and linker, if it needs to.

Additionally, assembly language files are now compiled using $(CC)
whether or not they need the preprocessor. This allows clang to build
.s files using its integrated assembler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.build

    r0f28387 ra0a273e  
    3636DEFS = -DBOOT -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
    3737
     38AFLAGS =
    3839LFLAGS = --fatal-warnings
    3940
    40 GCC_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    41         -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    42         -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    43         -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
     41# FIXME: This condition is a workaround for issue #693.
     42ifneq ($(BARCH),mips32)
     43        AFLAGS += --fatal-warnings
     44endif
     45
     46COMMON_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     47        -ffreestanding -fno-builtin -nostdlib -nostdinc \
     48        -fexec-charset=UTF-8 -finput-charset=UTF-8
     49
     50GCC_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    4451        -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
    4552        -pipe
    4653
    47 ICC_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    48         -ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
    49         -Werror-implicit-function-declaration -wd170
     54ICC_CFLAGS = -Wall -Wmissing-prototypes -Werror-implicit-function-declaration -wd170
    5055
    51 CLANG_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    52         -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    53         -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    54         -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
     56CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    5557        -Werror-implicit-function-declaration -Wwrite-strings \
    56         -pipe
     58        -pipe  -fno-stack-protector -fno-PIC
    5759
    5860ifeq ($(CONFIG_DEBUG),y)
    59         GCC_CFLAGS += -Werror
    60         ICC_CFLAGS += -Werror
     61        COMMON_CFLAGS += -Werror
    6162endif
    6263
    6364ifeq ($(CONFIG_LINE_DEBUG),y)
    64         GCC_CFLAGS += -g
    65         ICC_CFLAGS += -g
    66         CLANG_CFLAGS += -g
     65        COMMON_CFLAGS += -g
    6766endif
    6867
    6968ifeq ($(COMPILER),gcc_native)
    70         CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
     69        CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
    7170        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    7271endif
    7372
    7473ifeq ($(COMPILER),gcc_cross)
    75         CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
     74        CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
    7675        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    7776endif
    7877
    7978ifeq ($(COMPILER),gcc_helenos)
    80         CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
     79        CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
    8180        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    8281endif
     
    8483
    8584ifeq ($(COMPILER),icc)
    86         CFLAGS = $(ICC_CFLAGS) $(EXTRA_CFLAGS)
     85        CFLAGS = $(COMMON_CFLAGS) $(ICC_CFLAGS) $(EXTRA_CFLAGS)
    8786        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    8887endif
    8988
    9089ifeq ($(COMPILER),clang)
    91         CFLAGS = $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
     90        CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
    9291        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    9392endif
     
    105104endif
    106105
     106AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
     107
    107108$(BOOT_OUTPUT): $(RAW)
    108109        $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
     
    112113
    113114$(LINK): $(DEPEND)
    114         $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
     115        $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
    115116
    116117%.o: %.S $(DEPEND)
    117         $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
     118        $(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    118119ifeq ($(PRECHECK),y)
    119120        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
     
    127128
    128129%.o: %.s $(DEPEND)
    129         $(AS) $(AFLAGS) -o $@ $<
     130        $(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    130131ifeq ($(PRECHECK),y)
    131132        $(JOBFILE) $(JOB) $< $@ as asm
Note: See TracChangeset for help on using the changeset viewer.