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

Changeset a0a273e in mainline for uspace/Makefile.common


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
  • uspace/Makefile.common

    r0f28387 ra0a273e  
    160160LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl
    161161
    162 AFLAGS = --fatal-warnings
     162AFLAGS =
    163163LFLAGS = --fatal-warnings
     164
     165# FIXME: This condition is a workaround for issues #692 and #693.
     166ifneq ($(KARCH),ia64)
     167ifneq ($(KARCH),mips32)
     168        AFLAGS += --fatal-warnings
     169endif
     170endif
    164171
    165172ifeq ($(STATIC_NEEDED),y)
     
    228235        find . -name '*.lo' -follow -exec rm \{\} \;
    229236
    230 GCC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    231         -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    232         -finput-charset=UTF-8 -ffreestanding -fno-builtin -ffunction-sections \
    233         -nostdlib -nostdinc -Wall -Wextra -Wno-clobbered -Wno-unused-parameter \
    234         -Wmissing-prototypes -std=gnu99 -Werror-implicit-function-declaration \
    235         -Wwrite-strings -pipe -ggdb -D__$(ENDIANESS)__
    236 
    237 ICC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    238         -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    239         -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    240         -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
    241         -Werror-implicit-function-declaration -Wwrite-strings \
    242         -pipe -g -D__$(ENDIANESS)__
    243 
    244 # clang does not support following options but I am not sure whether
    245 # something won't break because of that:
    246 # -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) -finput-charset=UTF-8
    247 CLANG_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
    248         -ffreestanding -fno-builtin -nostdlib -nostdinc \
    249         -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
     237COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     238        -ffreestanding -fno-builtin -nostdlib -nostdinc -fexec-charset=UTF-8 \
     239        -finput-charset=UTF-8 -D__$(ENDIANESS)__
     240
     241GCC_CFLAGS = -ffunction-sections -Wall -Wextra -Wno-clobbered \
     242        -Wno-unused-parameter -Wmissing-prototypes -std=gnu99 \
     243        -Werror-implicit-function-declaration \
     244        -Wwrite-strings -pipe
     245
     246ICC_CFLAGS = -Wall -Wextra -Wno-clobbered -Wno-unused-parameter \
     247        -Wmissing-prototypes -Werror-implicit-function-declaration \
     248        -Wwrite-strings -pipe
     249
     250CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    250251        -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
    251         -integrated-as -pipe -g -target $(CLANG_TARGET) -D__$(ENDIANESS)__
    252 
    253 LIB_CFLAGS = $(CFLAGS) -fPIC
    254 LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
     252        -pipe -fno-stack-protector -fno-PIC
    255253
    256254ifeq ($(CONFIG_DEBUG),y)
    257         GCC_CFLAGS += -Werror
    258         ICC_CFLAGS += -Werror
     255        COMMON_CFLAGS += -Werror
    259256endif
    260257
     
    267264# Prepare for POSIX before including platform specific stuff
    268265ifeq ($(POSIX_COMPAT),y)
    269         CFLAGS = -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
     266        CFLAGS += -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
    270267        BASE_LIBS = $(LIBPOSIX_PREFIX)/libposixaslibc.a $(LIBPOSIX_PREFIX)/libc4posix.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    271268endif
     
    282279
    283280ifeq ($(COMPILER),gcc_cross)
    284         CFLAGS += $(GCC_CFLAGS)
     281        CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
    285282        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    286283endif
    287284
    288285ifeq ($(COMPILER),gcc_helenos)
    289         CFLAGS += $(GCC_CFLAGS)
     286        CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
    290287        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    291288endif
    292289
    293290ifeq ($(COMPILER),gcc_native)
    294         CFLAGS += $(GCC_CFLAGS)
     291        CFLAGS += $(COMMON_CFLAGS) $(GCC_CFLAGS)
    295292        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    296293endif
    297294
    298295ifeq ($(COMPILER),icc)
    299         CFLAGS += $(ICC_CFLAGS)
     296        CFLAGS += $(COMMON_CFLAGS) $(ICC_CFLAGS)
    300297        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    301298endif
    302299
    303300ifeq ($(COMPILER),clang)
    304         CFLAGS += $(CLANG_CFLAGS)
     301        CFLAGS += $(COMMON_CFLAGS) $(CLANG_CFLAGS)
    305302        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    306303endif
     304
     305LIB_CFLAGS = $(CFLAGS) -fPIC
     306LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
    307307
    308308ifneq ($(MAKECMDGOALS),clean)
    309309-include $(DEPEND)
    310310endif
     311
     312AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
     313LD_CFLAGS := $(addprefix -Xlinker ,$(LFLAGS))
    311314
    312315OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     
    372375
    373376%.o: %.S $(DEPEND)
    374         $(GCC) $(DEFS) $(GCC_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
     377        $(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    375378ifeq ($(PRECHECK),y)
    376379        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
     
    378381
    379382%.o: %.s $(DEPEND)
    380         $(AS) $(AFLAGS) -o $@ $<
     383        $(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    381384ifeq ($(PRECHECK),y)
    382385        $(JOBFILE) $(JOB) $< $@ as asm
     
    396399
    397400%.lo: %.S $(DEPEND)
    398         $(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
     401        $(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    399402ifeq ($(PRECHECK),y)
    400403        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
     
    402405
    403406%.lo: %.s $(DEPEND)
    404         $(AS) $(AFLAGS) -o $@ $<
     407        $(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
    405408ifeq ($(PRECHECK),y)
    406409        $(JOBFILE) $(JOB) $< $@ as asm
Note: See TracChangeset for help on using the changeset viewer.