Makefile revision 296012
1# $FreeBSD: head/gnu/lib/libgcc/Makefile 296012 2016-02-24 22:27:18Z bdrewery $ 2 3GCCDIR= ${.CURDIR}/../../../contrib/gcc 4GCCLIB= ${.CURDIR}/../../../contrib/gcclibs 5COMPILERRTDIR= ${.CURDIR}/../../../contrib/compiler-rt 6UNWINDINCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/include 7UNWINDSRCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/src 8 9SHLIB_NAME= libgcc_s.so.1 10SHLIBDIR?= /lib 11 12.include <src.opts.mk> 13# 14# libgcc is linked in last and thus cannot depend on ssp symbols coming 15# from earlier libraries. Disable stack protection for this library. 16# 17MK_SSP= no 18 19.include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt" 20 21.if ${TARGET_CPUARCH} == "arm" 22CFLAGS+= -DTARGET_ARM_EABI 23.endif 24 25.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}/config ${GCCDIR} 26 27CFLAGS+= -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \ 28 -DHAVE_GTHR_DEFAULT \ 29 -I${GCCLIB}/include \ 30 -I${GCCDIR}/config -I${GCCDIR} -I. \ 31 -I${.CURDIR}/../../usr.bin/cc/cc_tools 32 33LDFLAGS+= -nodefaultlibs 34LIBADD+= c 35 36SOBJS= # added to below in various ways depending on TARGET_CPUARCH 37 38#--------------------------------------------------------------------------- 39# 40# Library members defined in libgcc2.c. 41# When upgrading GCC, obtain the following list from mklibgcc.in 42# 43LIB2FUNCS= _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \ 44 _cmpdi2 _ucmpdi2 \ 45 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3 \ 46 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors \ 47 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab \ 48 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2 \ 49 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 \ 50 _divxc3 _divtc3 _bswapsi2 _bswapdi2 51.if ${COMPILER_TYPE} != "clang" || ${TARGET_CPUARCH} != "arm" 52LIB2FUNCS+= _clear_cache 53.endif 54 55# The floating-point conversion routines that involve a single-word integer. 56.for mode in sf df xf 57LIB2FUNCS+= _fixuns${mode}si 58.endfor 59 60# Likewise double-word routines. 61.if ${TARGET_CPUARCH} != "aarch64" && ${TARGET_CPUARCH} != "arm" && \ 62 ${TARGET_CPUARCH} != "riscv64" 63# These are implemented in an ARM specific file but will not be filtered out. 64# RISCVTODO: can't compile 65.for mode in sf df xf tf 66LIB2FUNCS+= _fix${mode}di _fixuns${mode}di 67LIB2FUNCS+= _floatdi${mode} _floatundi${mode} 68.endfor 69.endif 70 71LIB2ADD = $(LIB2FUNCS_EXTRA) 72LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA) 73 74# Additional sources to handle exceptions; overridden by targets as needed. 75.if ${MK_LLVM_LIBUNWIND} != "no" 76 77.PATH: ${COMPILERRTDIR}/lib/builtins 78.PATH: ${UNWINDSRCDIR} 79LIB2ADDEH = gcc_personality_v0.c \ 80 int_util.c \ 81 Unwind-EHABI.cpp \ 82 Unwind-sjlj.c \ 83 UnwindLevel1-gcc-ext.c \ 84 UnwindLevel1.c \ 85 UnwindRegistersRestore.S \ 86 UnwindRegistersSave.S \ 87 libunwind.cpp 88 89CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} 90.if empty(CXXFLAGS:M-std=*) 91CXXFLAGS+= -std=c++11 92.endif 93CXXFLAGS+= -fno-rtti 94STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC 95 96.else # MK_LLVM_LIBUNWIND 97 98.if ${TARGET_CPUARCH} == "arm" 99LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c 100.else 101LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \ 102 unwind-c.c 103.endif 104 105.endif # MK_LLVM_LIBUNWIND 106 107LIB2ADDEHSTATIC = $(LIB2ADDEH) 108LIB2ADDEHSHARED = $(LIB2ADDEH) 109 110# List of extra C and assembler files to add to static and shared libgcc2. 111# Assembler files should have names ending in `.asm'. 112LIB2FUNCS_EXTRA = 113 114# List of extra C and assembler files to add to static libgcc2. 115# Assembler files should have names ending in `.asm'. 116LIB2FUNCS_STATIC_EXTRA = 117 118# Defined in libgcc2.c, included only in the static library. 119# KAN: Excluded _sf_to_tf and _df_to_tf as TPBIT_FUNCS are not 120# built on any of our platforms. 121LIB2FUNCS_ST = _eprintf __gcc_bcmp 122 123FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \ 124 _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \ 125 _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \ 126 _sf_to_df _thenan_sf _sf_to_usi _usi_to_sf 127 128DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \ 129 _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \ 130 _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \ 131 _df_to_sf _thenan_df _df_to_usi _usi_to_df 132 133TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \ 134 _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \ 135 _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \ 136 _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf 137 138# These might cause a divide overflow trap and so are compiled with 139# unwinder info. 140LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 141 142#----------------------------------------------------------------------- 143# 144# Platform specific bits. 145# When upgrading GCC, get the following definitions from config/<cpu>/t-* 146# 147.if ${TARGET_CPUARCH} == "arm" 148# from config/arm/t-strongarm-elf 149CFLAGS+= -Dinhibit_libc -fno-inline 150CFLAGS.clang+= -fheinous-gnu-extensions 151 152LIB1ASMSRC = lib1funcs.asm 153LIB1ASMFUNCS = _dvmd_tls _bb_init_func 154# Some compilers generate __aeabi_ functions libgcc_s is missing 155LIBADD+= compiler_rt 156.endif 157 158.if ${TARGET_CPUARCH} == mips 159LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c 160# ABIs other than o32 need this 161.if ${TARGET_ARCH} != "mips" && ${TARGET_ARCH} != "mipsel" 162LIB2FUNCS_EXTRA+= floatdidf.c fixunsdfsi.c 163LIB2FUNCS_EXTRA+= floatdisf.c floatundidf.c 164LIB2FUNCS_EXTRA+= fixsfdi.c floatundisf.c 165LIB2FUNCS_EXTRA+= fixdfdi.c fixunssfsi.c 166.endif 167.endif 168 169.if ${TARGET_ARCH} == "powerpc" 170# from config/rs6000/t-ppccomm 171LIB2FUNCS_EXTRA = tramp.asm 172LIB2FUNCS_STATIC_EXTRA = eabi.asm 173.endif 174 175.if ${TARGET_ARCH} == "powerpc64" 176# from config/rs6000/t-ppccomm 177LIB2FUNCS_EXTRA = tramp.asm 178.endif 179 180.if ${TARGET_CPUARCH} == "sparc64" 181# from config/sparc/t-elf 182LIB1ASMSRC = lb1spc.asm 183LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 184.endif 185 186#----------------------------------------------------------------------- 187 188# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are 189# defined as optimized assembly code in LIB1ASMFUNCS. 190.if defined(LIB1ASMFUNCS) 191.for sym in ${LIB1ASMFUNCS} 192LIB2FUNCS:= ${LIB2FUNCS:S/${sym}//g} 193LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g} 194.endfor 195.endif 196 197COMMONHDRS= tm.h tconfig.h options.h gthr-default.h 198.if ${MK_LLVM_LIBUNWIND} != "no" 199# unwind.h is a generated file when MK_LLVM_LIBUNWIND == "no", and a stale 200# copy may be left behind in OBJDIR when switching, so remove it explicitly. 201beforebuild: 202 @rm -f ${.OBJDIR}/unwind.h 203.else 204COMMONHDRS+= unwind.h 205.endif 206 207#----------------------------------------------------------------------- 208# 209# Helpful shortcuts for compiler invocations. 210# 211HIDE = -fvisibility=hidden -DHIDE_EXPORTS 212CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC 213CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC 214CC_S = ${CC} -c ${CFLAGS} ${SHARED_CFLAGS} ${PICFLAG} -DSHARED 215 216#----------------------------------------------------------------------- 217# 218# Functions from libgcc2.c 219# 220STD_CFLAGS = 221DIV_CFLAGS = -fexceptions -fnon-call-exceptions 222 223STD_FUNCS = ${LIB2FUNCS} 224DIV_FUNCS = ${LIB2_DIVMOD_FUNCS} 225 226STD_CFILE = libgcc2.c 227DIV_CFILE = libgcc2.c 228 229OBJ_GRPS = STD DIV 230 231#----------------------------------------------------------------------- 232# 233# Floating point emulation functions 234# 235.if ${TARGET_CPUARCH} == "armNOT_YET" || \ 236 ${TARGET_CPUARCH} == "powerpc" || ${TARGET_CPUARCH} == "sparc64" 237 238FPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES -DFLOAT 239DPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES 240 241FPBIT_CFILE = config/fp-bit.c 242DPBIT_CFILE = config/fp-bit.c 243 244OBJ_GRPS += FPBIT DPBIT 245.endif 246 247#----------------------------------------------------------------------- 248# 249# Generic build rules for object groups defined above 250# 251.for T in ${OBJ_GRPS} 252${T}_OBJS_T = ${${T}_FUNCS:S/$/.o/} 253${T}_OBJS_P = ${${T}_FUNCS:S/$/.po/} 254${T}_OBJS_S = ${${T}_FUNCS:S/$/.So/} 255SOBJS += ${${T}_FUNCS:S/$/.So/} 256 257${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS} 258 ${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 259${${T}_OBJS_P}: ${${T}_CFILE} ${COMMONHDRS} 260 ${CC_P} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 261${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHDRS} 262 ${CC_S} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 263.endfor 264 265#----------------------------------------------------------------------- 266# 267# Extra objects coming from separate files 268# 269.if !empty(LIB2ADD) 270SOBJS += ${LIB2ADD:R:S/$/.So/} 271.endif 272 273#----------------------------------------------------------------------- 274# 275# Objects that should be in static library only. 276# 277SYMS_ST = ${LIB2FUNCS_ST} ${LIB2ADD_ST} 278STAT_OBJS_T = ${SYMS_ST:S/$/.o/} 279STAT_OBJS_P = ${SYMS_ST:S/$/.po/} 280STATICOBJS = ${SYMS_ST:S/$/.o/} 281 282${STAT_OBJS_T}: ${STD_CFILE} ${COMMONHDRS} 283 ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 284${STAT_OBJS_P}: ${STD_CFILE} ${COMMONHDRS} 285 ${CC_P} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 286 287#----------------------------------------------------------------------- 288# 289# Assembler files. 290# 291.if defined(LIB1ASMSRC) 292ASM_T = ${LIB1ASMFUNCS:S/$/.o/} 293ASM_P = ${LIB1ASMFUNCS:S/$/.po/} 294ASM_S = ${LIB1ASMFUNCS:S/$/.So/} 295ASM_V = ${LIB1ASMFUNCS:S/$/.vis/} 296SOBJS += ${LIB1ASMFUNCS:S/$/.So/} 297 298${ASM_T}: ${LIB1ASMSRC} ${.PREFIX}.vis 299 ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \ 300 -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis} 301${ASM_P}: ${LIB1ASMSRC} ${.PREFIX}.vis 302 ${CC} -x assembler-with-cpp -p -c ${CFLAGS} -DL${.PREFIX} \ 303 -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis} 304${ASM_S}: ${LIB1ASMSRC} 305 ${CC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} \ 306 -o ${.TARGET} ${.ALLSRC:N*.h} 307${ASM_V}: ${LIB1ASMSRC} 308 ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \ 309 -o ${.PREFIX}.vo ${.ALLSRC:N*.h} 310 ( ${NM} -pg ${.PREFIX}.vo | \ 311 awk 'NF == 3 && $$2 !~ /^[UN]$$/ { print "\t.hidden ", $$3 }'\ 312 ) > ${.TARGET} 313 314CLEANFILES += ${ASM_V} ${ASM_V:R:S/$/.vo/} 315.endif 316 317#----------------------------------------------------------------------- 318# 319# Exception handling / unwinding support. 320# 321EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/} 322EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/} 323EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/} 324EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN 325.if ${TARGET_CPUARCH} != "riscv64" 326# RISCVTODO: unwinding support 327SOBJS += ${EH_OBJS_S} 328.endif 329 330.for _src in ${LIB2ADDEHSTATIC:M*.c} 331${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS} 332 ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 333${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS} 334 ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 335.endfor 336.for _src in ${LIB2ADDEHSHARED:M*.c} 337${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS} 338 ${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 339.endfor 340 341 342#----------------------------------------------------------------------- 343# 344# Generated headers 345# 346${COMMONHDRS}: ${.CURDIR}/../../usr.bin/cc/cc_tools/Makefile 347 (cd ${.CURDIR}; ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}) 348 349CLEANFILES += ${COMMONHDRS} 350CLEANFILES += cs-*.h option* 351 352#----------------------------------------------------------------------- 353# 354# Build symbol version map 355# 356SHLIB_MKMAP = ${GCCDIR}/mkmap-symver.awk 357SHLIB_MKMAP_OPTS = 358SHLIB_MAPFILES = ${GCCDIR}/libgcc-std.ver 359.if ${TARGET_CPUARCH} == "arm" 360SHLIB_MAPFILES += ${GCCDIR}/config/arm/libgcc-bpabi.ver 361.endif 362VERSION_MAP = libgcc.map 363 364libgcc.map: ${SHLIB_MKMAP} ${SHLIB_MAPFILES} ${SOBJS} 365 ( ${NM} -pg ${SOBJS};echo %% ; \ 366 cat ${SHLIB_MAPFILES} \ 367 | sed -e '/^[ ]*#/d' \ 368 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \ 369 | ${CC} ${CFLAGS} -E -xassembler-with-cpp -; \ 370 ) | awk -f ${SHLIB_MKMAP} ${SHLIB_MKMAP_OPTS} > ${.TARGET} 371 372CLEANFILES += libgcc.map 373 374#----------------------------------------------------------------------- 375# 376# Build additional static libgcc_eh[_p].a libraries. 377# 378libgcc_eh.a: ${EH_OBJS_T} 379 @${ECHO} building static gcc_eh library 380 @rm -f ${.TARGET} 381 ${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q` 382 ${RANLIB} ${RANLIBFLAGS} ${.TARGET} 383 384_LIBS+= libgcc_eh.a 385 386.if ${MK_PROFILE} != "no" 387libgcc_eh_p.a: ${EH_OBJS_P} 388 @${ECHO} building profiled gcc_eh library 389 @rm -f ${.TARGET} 390 ${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q` 391 ${RANLIB} ${RANLIBFLAGS} ${.TARGET} 392 393_LIBS+= libgcc_eh_p.a 394.endif 395 396_libinstall: _lib-eh-install 397 398_lib-eh-install: 399.if ${MK_INSTALLLIB} != "no" 400 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 401 ${_INSTALLFLAGS} libgcc_eh.a ${DESTDIR}${LIBDIR} 402.endif 403.if ${MK_PROFILE} != "no" 404 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 405 ${_INSTALLFLAGS} libgcc_eh_p.a ${DESTDIR}${LIBDIR} 406.endif 407 408CLEANFILES+= libgcc_eh.a libgcc_eh_p.a ${EH_OBJS_T} ${EH_OBJS_P} 409 410.include <bsd.lib.mk> 411 412.SUFFIXES: .vis .vo 413