From 82c649de929450de329abe8a1c736279666f1345 Mon Sep 17 00:00:00 2001 From: dim Date: Mon, 30 Dec 2013 20:15:46 +0000 Subject: [PATCH] MFC r257532 (by adrian): Fix this build for clang. MFC r259730: To avoid having to explicitly test COMPILER_TYPE for setting clang-specific or gcc-specific flags, introduce the following new variables for use in Makefiles: CFLAGS.clang CFLAGS.gcc CXXFLAGS.clang CXXFLAGS.gcc In bsd.sys.mk, these get appended to the regular CFLAGS or CXXFLAGS for the right compiler. MFC r259913: For libstand and sys/boot, split off gcc-only flags into CFLAGS.gcc. MFC r259927: Fix pc98 build, by also forcing COMPILER_TYPE in sys/boot/pc98/boot2's Makefile. Pointy hat to: dim git-svn-id: svn://svn.freebsd.org/base/stable/9@260096 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- gnu/lib/csu/Makefile | 4 +--- lib/libstand/Makefile | 2 +- share/mk/bsd.sys.mk | 9 ++++++++- sys/boot/ficl/Makefile | 2 +- sys/boot/i386/Makefile.inc | 5 +++-- sys/boot/i386/boot2/Makefile | 7 ++++--- sys/boot/pc98/Makefile.inc | 5 +++-- sys/boot/pc98/boot2/Makefile | 1 + sys/boot/userboot/ficl/Makefile | 2 +- sys/boot/userboot/libstand/Makefile | 2 +- sys/boot/zfs/Makefile | 2 +- tools/tools/ath/athstats/Makefile | 10 ++++++++++ tools/tools/net80211/wlanstats/Makefile | 1 + usr.bin/mkcsmapper/Makefile.inc | 4 +--- 14 files changed, 37 insertions(+), 19 deletions(-) diff --git a/gnu/lib/csu/Makefile b/gnu/lib/csu/Makefile index 673d81cea..67c2f840d 100644 --- a/gnu/lib/csu/Makefile +++ b/gnu/lib/csu/Makefile @@ -15,9 +15,7 @@ OBJS= crtbegin.o crtend.o crtbeginT.o SOBJS= crtbegin.So crtend.So CSTD?= gnu89 CFLAGS+= -DIN_GCC -DHAVE_LD_EH_FRAME_HDR -DDT_CONFIG -D__GLIBC__=3 -.if ${COMPILER_TYPE} == "gcc" -CFLAGS+= -finhibit-size-directive -fno-toplevel-reorder -.endif +CFLAGS.gcc+= -finhibit-size-directive -fno-toplevel-reorder CFLAGS+= -fno-inline-functions -fno-exceptions \ -fno-zero-initialized-in-bss -fno-asynchronous-unwind-tables \ -fno-omit-frame-pointer diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index 75a45a8a4..edc7e9f71 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -21,7 +21,7 @@ CFLAGS+= -ffreestanding -Wformat CFLAGS+= -I${.CURDIR} .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float .endif .if ${MACHINE} == "pc98" diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 8dfcb5a2d..9a8a7e071 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -110,12 +110,19 @@ CWARNFLAGS+= -Wno-format CWARNFLAGS+= -Wno-unknown-pragmas .endif # IGNORE_PRAGMA -.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) +.if !defined(EARLY_BUILD) +.if ${COMPILER_TYPE} == "clang" CLANG_NO_IAS= -no-integrated-as CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret CFLAGS+= -Qunused-arguments +CFLAGS+= ${CFLAGS.clang} +CXXFLAGS+= ${CXXFLAGS.clang} +.else # !CLANG +CFLAGS+= ${CFLAGS.gcc} +CXXFLAGS+= ${CXXFLAGS.gcc} .endif # CLANG +.endif # !EARLY_BUILD .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile index 971faa73d..2e56b54af 100644 --- a/sys/boot/ficl/Makefile +++ b/sys/boot/ficl/Makefile @@ -9,7 +9,7 @@ CLEANFILES= softcore.c testmain testmain.o CFLAGS+= -ffreestanding .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -march=i386 -CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float .endif .if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm" diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc index f5faec730..83b4d18d1 100644 --- a/sys/boot/i386/Makefile.inc +++ b/sys/boot/i386/Makefile.inc @@ -5,8 +5,9 @@ BINDIR?= /boot LOADER_ADDRESS?=0x200000 -CFLAGS+= -march=i386 -ffreestanding -mpreferred-stack-boundary=2 \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float +CFLAGS+= -march=i386 -ffreestanding +CFLAGS.gcc+= -mpreferred-stack-boundary=2 +CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float LDFLAGS+= -nostdlib .if ${MACHINE_CPUARCH} == "amd64" diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 68e49edf5..8f1c150e8 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -23,10 +23,7 @@ BOOT2_UFS?= UFS1_AND_UFS2 #BOOT2_UFS?= UFS1_ONLY CFLAGS= -Os \ - -fno-guess-branch-probability \ -fomit-frame-pointer \ - -fno-unit-at-a-time \ - -mno-align-long-strings \ -mrtd \ -mregparm=3 \ -DUSE_XREAD \ @@ -43,6 +40,10 @@ CFLAGS= -Os \ -Winline --param max-inline-insns-single=100 \ ${CLANG_OPT_SMALL} +CFLAGS.gcc+= -fno-guess-branch-probability \ + -fno-unit-at-a-time \ + -mno-align-long-strings \ + LDFLAGS=-static -N --gc-sections # Pick up ../Makefile.inc early. diff --git a/sys/boot/pc98/Makefile.inc b/sys/boot/pc98/Makefile.inc index 857c8bcd7..b61330229 100644 --- a/sys/boot/pc98/Makefile.inc +++ b/sys/boot/pc98/Makefile.inc @@ -5,8 +5,9 @@ BINDIR?= /boot LOADER_ADDRESS?=0x200000 -CFLAGS+= -march=i386 -ffreestanding -mpreferred-stack-boundary=2 \ - -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float +CFLAGS+= -march=i386 -ffreestanding +CFLAGS.gcc+= -mpreferred-stack-boundary=2 +CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float CFLAGS+= -Os -DPC98 LDFLAGS+= -nostdlib diff --git a/sys/boot/pc98/boot2/Makefile b/sys/boot/pc98/boot2/Makefile index 00a28dea2..2b3e2c9be 100644 --- a/sys/boot/pc98/boot2/Makefile +++ b/sys/boot/pc98/boot2/Makefile @@ -4,6 +4,7 @@ # XXX: clang can compile the boot code just fine, but boot2 gets too big CC:= gcc +COMPILER_TYPE:= gcc FILES= boot boot1 boot2 diff --git a/sys/boot/userboot/ficl/Makefile b/sys/boot/userboot/ficl/Makefile index 42b9309f6..7bd8dd56a 100644 --- a/sys/boot/userboot/ficl/Makefile +++ b/sys/boot/userboot/ficl/Makefile @@ -16,7 +16,7 @@ CFLAGS+= -ffreestanding -fPIC CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 .endif .if ${MACHINE_CPUARCH} == "i386" -CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= -mno-sse3 .endif .if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm" diff --git a/sys/boot/userboot/libstand/Makefile b/sys/boot/userboot/libstand/Makefile index a5f5ba28b..e98cda10f 100644 --- a/sys/boot/userboot/libstand/Makefile +++ b/sys/boot/userboot/libstand/Makefile @@ -28,7 +28,7 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 .endif .if ${MACHINE_CPUARCH} == "i386" -CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= -mno-sse3 .endif .if ${MACHINE} == "pc98" diff --git a/sys/boot/zfs/Makefile b/sys/boot/zfs/Makefile index 9b900e421..24076437d 100644 --- a/sys/boot/zfs/Makefile +++ b/sys/boot/zfs/Makefile @@ -13,7 +13,7 @@ CFLAGS+= -I${.CURDIR}/../../cddl/boot/zfs CFLAGS+= -ffreestanding .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -march=i386 -CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float .endif .if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm" diff --git a/tools/tools/ath/athstats/Makefile b/tools/tools/ath/athstats/Makefile index b1b976619..d69a7f7f1 100644 --- a/tools/tools/ath/athstats/Makefile +++ b/tools/tools/ath/athstats/Makefile @@ -1,9 +1,17 @@ # $FreeBSD$ +NO_MAN=1 + +.include + .PATH: ${.CURDIR}/../../../../sys/dev/ath/ath_hal PROG= athstats +# Because of a clang preprocessor parser limitation causing this +# to not compile, use gcc for now. +#CC= gcc + SRCS= main.c statfoo.c athstats.c opt_ah.h ah_osdep.h CLEANFILES+= opt_ah.h @@ -13,6 +21,8 @@ CLEANFILES+= opt_ah.h CFLAGS+=-DATH_SUPPORT_ANI CFLAGS+=-DATH_SUPPORT_TDMA +CFLAGS.clang+= -fbracket-depth=512 + opt_ah.h: echo "#define AH_DEBUG 1" > opt_ah.h echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h diff --git a/tools/tools/net80211/wlanstats/Makefile b/tools/tools/net80211/wlanstats/Makefile index da364952b..9284025c4 100644 --- a/tools/tools/net80211/wlanstats/Makefile +++ b/tools/tools/net80211/wlanstats/Makefile @@ -5,5 +5,6 @@ BINDIR= /usr/local/bin NO_MAN= SRCS= statfoo.c wlanstats.c main.c +CFLAGS.clang+= -fbracket-depth=512 .include diff --git a/usr.bin/mkcsmapper/Makefile.inc b/usr.bin/mkcsmapper/Makefile.inc index e0acc9b53..5a4cc6faa 100644 --- a/usr.bin/mkcsmapper/Makefile.inc +++ b/usr.bin/mkcsmapper/Makefile.inc @@ -6,6 +6,4 @@ SRCS+= lex.l yacc.y CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../mkcsmapper \ -I${.CURDIR}/../../lib/libc/iconv \ -I${.CURDIR}/../../lib/libiconv_modules/mapper_std -.if ${COMPILER_TYPE} == "gcc" -CFLAGS+= --param max-inline-insns-single=64 -.endif +CFLAGS.gcc+= --param max-inline-insns-single=64 -- 2.45.0