Makefile revision 294590
1# $FreeBSD: head/gnu/lib/libgcc/Makefile 294590 2016-01-22 19:03:39Z emaste $ 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 36OBJS= # 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# These are implemented in an ARM specific file but will not be filtered out 63.for mode in sf df xf tf 64LIB2FUNCS+= _fix${mode}di _fixuns${mode}di 65LIB2FUNCS+= _floatdi${mode} _floatundi${mode} 66.endfor 67.endif 68 69LIB2ADD = $(LIB2FUNCS_EXTRA) 70LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA) 71 72# Additional sources to handle exceptions; overridden by targets as needed. 73.if ${MK_LLVM_LIBUNWIND} != "no" 74 75.PATH: ${COMPILERRTDIR}/lib/builtins 76.PATH: ${UNWINDSRCDIR} 77LIB2ADDEH = gcc_personality_v0.c \ 78 int_util.c \ 79 Unwind-EHABI.cpp \ 80 Unwind-sjlj.c \ 81 UnwindLevel1-gcc-ext.c \ 82 UnwindLevel1.c \ 83 UnwindRegistersRestore.S \ 84 UnwindRegistersSave.S \ 85 libunwind.cpp 86 87CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} 88.if empty(CXXFLAGS:M-std=*) 89CXXFLAGS+= -std=c++11 90.endif 91CXXFLAGS+= -fno-rtti 92STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC 93 94.else # MK_LLVM_LIBUNWIND 95 96.if ${TARGET_CPUARCH} == "arm" 97LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c 98.else 99LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \ 100 unwind-c.c 101.endif 102 103.endif # MK_LLVM_LIBUNWIND 104 105LIB2ADDEHSTATIC = $(LIB2ADDEH) 106LIB2ADDEHSHARED = $(LIB2ADDEH) 107 108# List of extra C and assembler files to add to static and shared libgcc2. 109# Assembler files should have names ending in `.asm'. 110LIB2FUNCS_EXTRA = 111 112# List of extra C and assembler files to add to static libgcc2. 113# Assembler files should have names ending in `.asm'. 114LIB2FUNCS_STATIC_EXTRA = 115 116# Defined in libgcc2.c, included only in the static library. 117# KAN: Excluded _sf_to_tf and _df_to_tf as TPBIT_FUNCS are not 118# built on any of our platforms. 119LIB2FUNCS_ST = _eprintf __gcc_bcmp 120 121FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \ 122 _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \ 123 _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \ 124 _sf_to_df _thenan_sf _sf_to_usi _usi_to_sf 125 126DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \ 127 _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \ 128 _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \ 129 _df_to_sf _thenan_df _df_to_usi _usi_to_df 130 131TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \ 132 _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \ 133 _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \ 134 _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf 135 136# These might cause a divide overflow trap and so are compiled with 137# unwinder info. 138LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 139 140#----------------------------------------------------------------------- 141# 142# Platform specific bits. 143# When upgrading GCC, get the following definitions from config/<cpu>/t-* 144# 145.if ${TARGET_CPUARCH} == "arm" 146# from config/arm/t-strongarm-elf 147CFLAGS+= -Dinhibit_libc -fno-inline 148CFLAGS.clang+= -fheinous-gnu-extensions 149 150LIB1ASMSRC = lib1funcs.asm 151LIB1ASMFUNCS = _dvmd_tls _bb_init_func 152# Some compilers generate __aeabi_ functions libgcc_s is missing 153LIBADD+= compiler_rt 154.endif 155 156.if ${TARGET_CPUARCH} == mips 157LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c 158# ABIs other than o32 need this 159.if ${TARGET_ARCH} != "mips" && ${TARGET_ARCH} != "mipsel" 160LIB2FUNCS_EXTRA+= floatdidf.c fixunsdfsi.c 161LIB2FUNCS_EXTRA+= floatdisf.c floatundidf.c 162LIB2FUNCS_EXTRA+= fixsfdi.c floatundisf.c 163LIB2FUNCS_EXTRA+= fixdfdi.c fixunssfsi.c 164.endif 165.endif 166 167.if ${TARGET_ARCH} == "powerpc" 168# from config/rs6000/t-ppccomm 169LIB2FUNCS_EXTRA = tramp.asm 170LIB2FUNCS_STATIC_EXTRA = eabi.asm 171.endif 172 173.if ${TARGET_ARCH} == "powerpc64" 174# from config/rs6000/t-ppccomm 175LIB2FUNCS_EXTRA = tramp.asm 176.endif 177 178.if ${TARGET_CPUARCH} == "sparc64" 179# from config/sparc/t-elf 180LIB1ASMSRC = lb1spc.asm 181LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 182.endif 183 184#----------------------------------------------------------------------- 185 186# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are 187# defined as optimized assembly code in LIB1ASMFUNCS. 188.if defined(LIB1ASMFUNCS) 189.for sym in ${LIB1ASMFUNCS} 190LIB2FUNCS:= ${LIB2FUNCS:S/${sym}//g} 191LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g} 192.endfor 193.endif 194 195COMMONHDRS= tm.h tconfig.h options.h gthr-default.h 196.if ${MK_LLVM_LIBUNWIND} != "no" 197# unwind.h is a generated file when MK_LLVM_LIBUNWIND == "no", and a stale 198# copy may be left behind in OBJDIR when switching, so remove it explicitly. 199beforebuild: 200 @rm -f ${.OBJDIR}/unwind.h 201.else 202COMMONHDRS+= unwind.h 203.endif 204 205#----------------------------------------------------------------------- 206# 207# Helpful shortcuts for compiler invocations. 208# 209HIDE = -fvisibility=hidden -DHIDE_EXPORTS 210CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC 211CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC 212CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED 213 214#----------------------------------------------------------------------- 215# 216# Functions from libgcc2.c 217# 218STD_CFLAGS = 219DIV_CFLAGS = -fexceptions -fnon-call-exceptions 220 221STD_FUNCS = ${LIB2FUNCS} 222DIV_FUNCS = ${LIB2_DIVMOD_FUNCS} 223 224STD_CFILE = libgcc2.c 225DIV_CFILE = libgcc2.c 226 227OBJ_GRPS = STD DIV 228 229#----------------------------------------------------------------------- 230# 231# Floating point emulation functions 232# 233.if ${TARGET_CPUARCH} == "armNOT_YET" || \ 234 ${TARGET_CPUARCH} == "powerpc" || ${TARGET_CPUARCH} == "sparc64" 235 236FPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES -DFLOAT 237DPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES 238 239FPBIT_CFILE = config/fp-bit.c 240DPBIT_CFILE = config/fp-bit.c 241 242OBJ_GRPS += FPBIT DPBIT 243.endif 244 245#----------------------------------------------------------------------- 246# 247# Generic build rules for object groups defined above 248# 249.for T in ${OBJ_GRPS} 250${T}_OBJS_T = ${${T}_FUNCS:S/$/.o/} 251${T}_OBJS_P = ${${T}_FUNCS:S/$/.po/} 252${T}_OBJS_S = ${${T}_FUNCS:S/$/.So/} 253OBJS += ${${T}_FUNCS:S/$/.o/} 254 255${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS} 256 ${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 257${${T}_OBJS_P}: ${${T}_CFILE} ${COMMONHDRS} 258 ${CC_P} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 259${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHDRS} 260 ${CC_S} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 261.endfor 262 263#----------------------------------------------------------------------- 264# 265# Extra objects coming from separate files 266# 267.if !empty(LIB2ADD) 268OBJS += ${LIB2ADD:R:S/$/.o/} 269SOBJS += ${LIB2ADD:R:S/$/.So/} 270POBJS += ${LIB2ADD:R:S/$/.po/} 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/} 296OBJS += ${LIB1ASMFUNCS:S/$/.o/} 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 325SOBJS += ${EH_OBJS_S} 326 327.for _src in ${LIB2ADDEHSTATIC:M*.c} 328${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS} 329 ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 330${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS} 331 ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 332.endfor 333.for _src in ${LIB2ADDEHSHARED:M*.c} 334${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS} 335 ${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 336.endfor 337 338 339#----------------------------------------------------------------------- 340# 341# Generated headers 342# 343${COMMONHDRS}: ${.CURDIR}/../../usr.bin/cc/cc_tools/Makefile 344 (cd ${.CURDIR}; ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}) 345 346CLEANFILES += ${COMMONHDRS} 347CLEANFILES += cs-*.h option* 348 349#----------------------------------------------------------------------- 350# 351# Build symbol version map 352# 353SHLIB_MKMAP = ${GCCDIR}/mkmap-symver.awk 354SHLIB_MKMAP_OPTS = 355SHLIB_MAPFILES = ${GCCDIR}/libgcc-std.ver 356.if ${TARGET_CPUARCH} == "arm" 357SHLIB_MAPFILES += ${GCCDIR}/config/arm/libgcc-bpabi.ver 358.endif 359VERSION_MAP = libgcc.map 360 361libgcc.map: ${SHLIB_MKMAP} ${SHLIB_MAPFILES} ${SOBJS} ${OBJS:R:S/$/.So/} 362 ( ${NM} -pg ${SOBJS};echo %% ; \ 363 cat ${SHLIB_MAPFILES} \ 364 | sed -e '/^[ ]*#/d' \ 365 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \ 366 | ${CC} ${CFLAGS} -E -xassembler-with-cpp -; \ 367 ) | awk -f ${SHLIB_MKMAP} ${SHLIB_MKMAP_OPTS} > ${.TARGET} 368 369CLEANFILES += libgcc.map 370 371#----------------------------------------------------------------------- 372# 373# Build additional static libgcc_eh[_p].a libraries. 374# 375libgcc_eh.a: ${EH_OBJS_T} 376 @${ECHO} building static gcc_eh library 377 @rm -f ${.TARGET} 378 @${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q` 379 ${RANLIB} ${RANLIBFLAGS} ${.TARGET} 380 381_LIBS+= libgcc_eh.a 382 383.if ${MK_PROFILE} != "no" 384libgcc_eh_p.a: ${EH_OBJS_P} 385 @${ECHO} building profiled gcc_eh library 386 @rm -f ${.TARGET} 387 @${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q` 388 ${RANLIB} ${RANLIBFLAGS} ${.TARGET} 389 390_LIBS+= libgcc_eh_p.a 391.endif 392 393_libinstall: _lib-eh-install 394 395_lib-eh-install: 396.if ${MK_INSTALLLIB} != "no" 397 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 398 ${_INSTALLFLAGS} libgcc_eh.a ${DESTDIR}${LIBDIR} 399.endif 400.if ${MK_PROFILE} != "no" 401 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 402 ${_INSTALLFLAGS} libgcc_eh_p.a ${DESTDIR}${LIBDIR} 403.endif 404 405CLEANFILES+= libgcc_eh.a libgcc_eh_p.a ${EH_OBJS_T} ${EH_OBJS_P} 406 407.include <bsd.lib.mk> 408 409.SUFFIXES: .vis .vo 410