4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright 2016 Joyent, Inc.
25 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
26 # Copyright 2013 Garrett D'Amore <garrett@damore.org>
27 # Copyright 2017 Nexenta Systems, Inc.
30 LIBCDIR= $(SRC)/lib/libc
36 # objects are grouped by source directory
38 # Symbol capabilities objects.
40 $(LIBCDIR)/capabilities/sun4u/sparc/pics/symcap.o \
41 $(LIBCDIR)/capabilities/sun4u-opl/sparc/pics/symcap.o \
42 $(LIBCDIR)/capabilities/sun4u-us3-hwcap1/sparc/pics/symcap.o \
43 $(LIBCDIR)/capabilities/sun4u-us3-hwcap2/sparc/pics/symcap.o \
44 $(LIBCDIR)/capabilities/sun4v-hwcap1/sparc/pics/symcap.o \
45 $(LIBCDIR)/capabilities/sun4v-hwcap2/sparc/pics/symcap.o
111 $(__GNUC)FPASMOBJS += \
147 arc4random_uniform.o \
177 sync_instruction_memory.o
179 # sysobjs that contain large-file interfaces
332 _lwp_mutex_unlock.o \
347 # objects under $(LIBCDIR)/port which contain transitional large file interfaces
357 # objects from source under $(LIBCDIR)/port
410 ascii_strncasecmp.o \
675 # c89 variants to support 32-bit size of c89 u/intmax_t (32-bit libc only)
687 # portable stdio objects that contain large file interfaces.
688 # Note: fopen64 is a special case, as we build it small.
933 # objects that implement the transitional large file API
1050 $(THREADSMACHOBJS) \
1064 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
1065 # modules whose source is provided in the $(SRC)/lib/common directory.
1066 # This must be done because otherwise the Sun C compiler would insert
1067 # its own versions of these modules and those versions contain code
1068 # to call out to C++ initialization functions. Such C++ initialization
1069 # functions can call back into libc before thread initialization is
1070 # complete and this leads to segmentation violations and other problems.
1071 # Since libc contains no C++ code, linking with the minimal crti.o and
1072 # crtn.o modules is safe and avoids the problems described above.
1073 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
1074 CRTSRCS= ../../common/sparc
1076 # include common library definitions
1077 include $(SRC)/lib/Makefile.lib
1079 # we need to override the default SONAME here because we might
1080 # be building a variant object (still libc.so.1, but different filename)
1083 CFLAGS += $(CCVERBOSE)
1085 # This is necessary to avoid problems with calling _ex_unwind().
1086 # We probably don't want any inlining anyway.
1089 CERRWARN += -_gcc=-Wno-parentheses
1090 CERRWARN += -_gcc=-Wno-switch
1091 CERRWARN += -_gcc=-Wno-uninitialized
1092 CERRWARN += -_gcc=-Wno-unused-value
1093 CERRWARN += -_gcc=-Wno-unused-label
1094 CERRWARN += -_gcc=-Wno-unused-variable
1095 CERRWARN += -_gcc=-Wno-type-limits
1096 CERRWARN += -_gcc=-Wno-char-subscripts
1097 CERRWARN += -_gcc=-Wno-clobbered
1098 CERRWARN += -_gcc=-Wno-unused-function
1099 CERRWARN += -_gcc=-Wno-address
1101 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1102 # enables ASSERT() checking in the threads portion of the library.
1103 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1105 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1107 # Make string literals read-only to save memory.
1108 CFLAGS += $(XSTRCONST)
1110 ALTPICS= $(TRACEOBJS:%=pics/%)
1112 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) $(EXTPICS)
1114 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1116 CFLAGS += $(EXTN_CFLAGS)
1117 CPPFLAGS= -D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1118 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1119 ASFLAGS= $(EXTN_ASFLAGS) -K pic -P -D__STDC__ -D_ASM $(CPPFLAGS) $(sparc_AS_XARCH)
1121 # As a favor to the dtrace syscall provider, libc still calls the
1122 # old syscall traps that have been obsoleted by the *at() interfaces.
1123 # Delete this to compile libc using only the new *at() system call traps
1124 CPPFLAGS += -D_RETAIN_OLD_SYSCALLS
1126 # Inform the run-time linker about libc specialized initialization
1127 RTLDINFO = -z rtldinfo=tls_rtldinfo
1128 DYNFLAGS += $(RTLDINFO)
1130 # Force libc's internal references to be resolved immediately upon loading
1131 # in order to avoid critical region problems. Since almost all libc symbols
1132 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1135 DYNFLAGS += -e __rtboot
1136 DYNFLAGS += $(EXTN_DYNFLAGS)
1138 # Inform the kernel about the initial DTrace area (in case
1139 # libc is being used as the interpreter / runtime linker).
1140 DTRACE_DATA = -zdtrace=dtrace_data
1141 DYNFLAGS += $(DTRACE_DATA)
1143 # DTrace needs an executable data segment.
1146 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1148 # Override this top level flag so the compiler builds in its native
1149 # C99 mode. This has been enabled to support the complex arithmetic
1151 C99MODE= $(C99_ENABLE)
1153 # libc method of building an archive
1154 # The "$(GREP) -v ' L '" part is necessary only until
1155 # lorder is fixed to ignore thread-local variables.
1156 BUILD.AR= $(RM) $@ ; \
1157 $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1159 # extra files for the clean target
1161 $(LIBCDIR)/port/gen/errlst.c \
1162 $(LIBCDIR)/port/gen/new_list.c \
1165 $(LIBCBASE)/crt/_rtld.s \
1166 $(LIBCBASE)/crt/_rtbootld.s \
1172 CLOBBERFILES += $(LIB_PIC)
1174 # list of C source for lint
1176 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1177 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1178 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1179 $(DTRACEOBJS:%.o=$(SRC)/common/dtrace/%.c) \
1180 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1181 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1182 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1183 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1184 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1185 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1186 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1187 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1188 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1189 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1190 $(SECFLAGSOBJS:%.o=$(SRC)/common/secflags/%.c) \
1191 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1192 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1193 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1194 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1195 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1196 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1197 $(LIBCBASE)/crt/_ftou.c \
1198 $(LIBCBASE)/gen/_xregs_clrptr.c \
1199 $(LIBCBASE)/gen/byteorder.c \
1200 $(LIBCBASE)/gen/ecvt.c \
1201 $(LIBCBASE)/gen/endian.c \
1202 $(LIBCBASE)/gen/getctxt.c \
1203 $(LIBCBASE)/gen/lmul.c \
1204 $(LIBCBASE)/gen/makectxt.c \
1205 $(LIBCBASE)/gen/siginfolst.c \
1206 $(LIBCBASE)/gen/siglongjmp.c \
1207 $(LIBCBASE)/gen/swapctxt.c \
1208 $(LIBCBASE)/sys/ptrace.c \
1209 $(LIBCBASE)/sys/uadmin.c
1211 # conditional assignments
1212 $(DYNLIB) := CRTI = crti.o
1213 $(DYNLIB) := CRTN = crtn.o
1215 # Files which need the threads .il inline template
1250 thread_interface.o \
1256 $(TIL:%=pics/%) := CFLAGS += $(LIBCBASE)/threads/sparc.il
1258 # special kludge for inlines with 'cas':
1259 pics/rwlock.o pics/synch.o pics/lwp.o pics/door_calls.o := \
1260 sparc_CFLAGS += -_gcc=-Wa,-xarch=v8plus
1262 # Files in port/fp subdirectory that need base.il inline template
1267 $(IL:%=pics/%) := CFLAGS += $(LIBCBASE)/fp/base.il
1269 # Files in fp subdirectory which need __quad.il inline template
1286 $(QIL:%=pics/%) := CFLAGS += $(LIBCDIR)/$(MACH)/fp/__quad.il
1287 pics/_Q%.o := sparc_COPTFLAG = -xO4 -dalign
1288 pics/__quad%.o := sparc_COPTFLAG = -xO4 -dalign
1290 # large-file-aware components that should be built large
1292 $(COMSYSOBJS64:%=pics/%) := \
1293 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1295 $(SYSOBJS64:%=pics/%) := \
1296 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1298 $(PORTGEN64:%=pics/%) := \
1299 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1301 $(PORTREGEX64:%=pics/%) := \
1302 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1304 $(PORTSTDIO64:%=pics/%) := \
1305 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1307 $(PORTSYS64:%=pics/%) := \
1308 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1310 $(PORTSTDIO_W:%=pics/%) := \
1313 $(PORTPRINT_W:%=pics/%) := \
1316 # printf/scanf functions to support c89-sized intmax_t variables
1317 $(PORTPRINT_C89:%=pics/%) := \
1318 CPPFLAGS += -D_C89_INTMAX32
1320 $(PORTSTDIO_C89:%=pics/%) := \
1321 CPPFLAGS += -D_C89_INTMAX32
1323 $(PORTI18N_COND:%=pics/%) := \
1324 CPPFLAGS += -D_WCS_LONGLONG
1326 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1328 # Files which need extra optimization
1329 pics/getenv.o := sparc_COPTFLAG = -xO4
1333 all: $(LIBS) $(LIB_PIC)
1335 lint := CPPFLAGS += -I$(LIBCDIR)/$(MACH)/fp
1336 lint := CPPFLAGS += -D_MSE_INT_H -D_LCONV_C99
1337 lint := LINTFLAGS += -mn
1340 @echo $(LINT.c) ... $(LDLIBS)
1341 @$(LINT.c) $(SRCS) $(LDLIBS)
1343 $(LINTLIB):= SRCS=$(LIBCDIR)/port/llib-lc
1344 $(LINTLIB):= CPPFLAGS += -D_MSE_INT_H
1345 $(LINTLIB):= LINTFLAGS=-nvx
1347 # object files that depend on inline template
1348 $(TIL:%=pics/%): $(LIBCBASE)/threads/sparc.il
1349 $(IL:%=pics/%): $(LIBCBASE)/fp/base.il
1350 $(QIL:%=pics/%): $(LIBCDIR)/$(MACH)/fp/__quad.il
1352 # include common libc targets
1353 include $(LIBCDIR)/Makefile.targ
1355 # We need to strip out all CTF and DOF data from the static library
1356 $(LIB_PIC) := DIR = pics
1357 $(LIB_PIC): pics $$(PICS)
1359 $(MCS) -d -n .SUNW_ctf $@ > /dev/null 2>&1
1360 $(MCS) -d -n .SUNW_dof $@ > /dev/null 2>&1
1361 $(AR) -ts $@ > /dev/null
1365 $(STRETS:%=pics/%): $(LIBCBASE)/crt/stret.s
1366 $(AS) $(ASFLAGS) -DSTRET$(@F:stret%.o=%) $(LIBCBASE)/crt/stret.s -o $@
1369 $(LIBCBASE)/crt/_rtbootld.s: $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
1370 $(CC) $(CPPFLAGS) $(CTF_FLAGS) -O -S -K pic \
1371 $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
1372 $(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
1373 $(RM) $(LIBCBASE)/crt/_rtld.s
1375 # partially built from C source
1376 pics/_rtbootld.o: $(LIBCBASE)/crt/_rtbootld.s
1377 $(AS) $(ASFLAGS) $(LIBCBASE)/crt/_rtbootld.s -o $@
1381 _lwp_mutex_unlock.o \
1390 $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I.
1392 $(ASSYMDEP_OBJS:%=pics/%): assym.h
1394 # assym.h build rules
1396 assym.h := CFLAGS += -g
1398 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
1400 genassym: $(GENASSYM_C)
1401 $(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
1402 $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
1404 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
1406 assym.h: $(OFFSETS) genassym
1407 $(OFFSETS_CREATE) <$(OFFSETS) >$@
1410 # derived C source and related explicit dependencies
1411 $(LIBCDIR)/port/gen/errlst.c + \
1412 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1413 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1415 pics/errlst.o: $(LIBCDIR)/port/gen/errlst.c
1417 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c