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