Commit Graph

383 Commits

Author SHA1 Message Date
christos
6e8b36d108 1. if ${LIBISPRIVATE} == "pic", create _pic.a so that we can embed the library
to another shared object
2. Don't compare ${LIBISPRIVATE} to "yes", because there are 3 places in
   Makefiles which set it to empty (this was a bug)
3. For private libraries, don't create .so* files
2020-06-01 14:39:14 +00:00
christos
dc0fae96c0 Allow LIBISPRIVATE to build a pic version of itself for embedding into
other shared libraries.
2020-05-30 19:51:32 +00:00
maxv
e4eb677baa Pass -Wno-unused-command-line-argument for LLVM, discussed on
tech-toolchain@.
2020-05-10 06:38:24 +00:00
kamil
1a5f018b01 Enhance the support of LLVM sanitizers
Define _REENTRANT for MKSANITIZER build. This is needed for at least stdio
code. This caused new build issued with duplicated symbols in few places
and rump kernel code picking different code paths borrowed from libc.
Handle all this in one go.

Add bsd.sanitizer.mk to share common code used by programs and libraries.

Switch from realall to beforeinstall target in .syms files. This is more
reliable in MKSANITIZER.
2019-08-27 22:48:53 +00:00
christos
0a4f449bbb Most of the mv operations are to move temporary files to their final place.
Some use -f, others don't. This can lead to spurious build failures when
the user performing the build changes. Centralize, and always use -f.
2019-01-21 21:11:54 +00:00
christos
9d350ea742 Since g++ uses stdc++_p when building with -pg make this PIC on the
platforms where PIC is available, so that linking shared objects with
-pg works, without needing to create a shared library version of the
profiled libraries.
2019-01-06 17:02:32 +00:00
kamil
031cfa7ff2 Introduce MKLIBCSANITIZER in the share/mk rules
Add flags that are required to build a program and a dynamically loaded
library.

Propagade LIBCSANITIZERFLAGS to CFLAGS and CXXFLAGS.

LDFLAGS is not changed on purpose, as a libcsanitizer is inside libc
and no external dependencies are needed.

Register NOLIBCSANITIZER, as certain distribution parts will need to be
skipped.
2018-07-25 23:34:25 +00:00
kamil
eb682ff828 Add a framework for renaming symbols in libc&co for MKSANITIZER
A new keyword SANITIZER_RENAME_SYMBOL. It's a variable that has specified
a list of symbols to be renamed in a processor in order to remove naming
conflicts with public symbols in libc/m/pthread/rt.

This renaming will occur for libraries and programs.
A symbol with a conflicting 'name', will be renamed to '__mksanitizer_name'.

Based on an idea by <christos>
2018-06-25 17:58:36 +00:00
kamil
64a497de12 Refactor MKSANITIZER flags in mk rules
Introduce a new variable SANITIZERFLAGS that contains all the sanitizer
specific flags. These flags are designed to be passed to CFLAGS, CXXFLAGS
and LDFLAGS.

Pass SANITIZERFLAGS in bsd.prog.mk rules to CFLAGS, CXXFLAGS and LDFLAGS.

Pass SANITIZERFLAGS in bsd.lib.mk rules to *_pic.a build flags. The *_pic.a
libraries are designed to construct .so libraries. All .so libraries with
few exceptions are expected to be prebuilt with a sanitizer. Another
purpuse of *_pic.a files can be constructing static PIE programs, however
they are not supported as of now and there is no sanitization of static
programs either.

Once MKSTATICPIE will be supported, it will be initially incompatible with
MKSANITIZER.

This change also makes it easier to build other targets like kernel and
kernel modules without userland sanitizers.

No functional change intended for MKSANITIZER=no users.
2018-06-21 11:24:38 +00:00
christos
56e6b77faa Elide -nostdinc from LINK.c when linking object files since clang complains
about unused argument. Note that we can't remove CPPFLAGS from LINK.c because
it is used in the "shuttle rules" (from .c to executable).
2018-06-05 15:37:52 +00:00
christos
4cb6d5fb56 Add rules for building relocatable objects to avoid having random Makefiles
use ${LD} ${LDFLAGS} -r which does not work if we specify MKRELRO since
LDFLAGS is supposed to be passed to LINK.c not LD directly (although some
of the flags work).
2018-06-05 00:56:51 +00:00
christos
703982a7f9 remove ugly profiling hack now that the compiler is fixed. 2017-05-29 03:52:43 +00:00
christos
b71afc21c9 XXX: Remove -fPIE for profiled libraries because this breaks relocations for
the call to __mcount.
2017-05-23 00:54:13 +00:00
chs
4da28eb39f fix another parallel-build race with MKDEBUG=yes by creating the .so.link
with a temporary name and renaming to the final name only after
the file is fully written.
2017-04-24 17:09:37 +00:00
ozaki-r
1300188462 Introduce MKSTRIPSYM build option
If it's yes, all local symbols of shared libraries are stripped
(default). If it's no, only temporary local symbols are stripped;
for example, symbols of static functions are kept. Keeping such
symbols is useful on using DTrace for userland libraries and
getting a backtrace from a rump server loading modules (shared
libraries).

Proposed and discussed on tech-kern and tech-toolchain
2017-04-20 09:29:10 +00:00
christos
13da18a371 - centralize setting of MK* vars in bsd.own.mk
- make sure that the default setting of all vars is done in _MKVARS.{yes,no}
  if possible.
2017-01-08 17:40:44 +00:00
mrg
e2bee4685a remove conditionals that are always true with GCC >= 4.8. 2016-03-12 23:08:58 +00:00
christos
0048ede9cd Revert and leave broken. 2016-02-27 23:51:34 +00:00
christos
16fbfcab6b Don't build archive libs with -fPIC breaks static binaries and profilig. 2016-02-27 20:36:17 +00:00
christos
6c0101debe Add NODEBUG 2016-02-21 03:34:27 +00:00
christos
dc084e400e Introduce NOPIE and NOCTF so that standalone programs build properly. 2016-01-31 15:30:14 +00:00
uebayasi
45ccdffc42 Revert previous. It was not wrong, but not necessary for everyone.
(If really wanted, *.a generation rule can be easily overriden locally.)
2015-09-08 16:06:42 +00:00
uebayasi
463bd4e74c Order object build alphabetically. 2015-09-07 06:42:07 +00:00
tsutsui
e2c773cb5b Revert rev 1.359 which broke libsa builds. PR/50101 2015-07-29 14:35:04 +00:00
joerg
a7c9fae5a0 Simplify the build of library archives by no longer doing a topological
sort.
2015-07-20 12:20:26 +00:00
mrg
69443c441c fix MKDEBUG vs parallel builds. split the creation of the final
.so file from the main link of it, and use the main file as the
input for both the .so output and the .so.debug file.  for MKDEBUG
builds we now:

	(a) create the (new) .so.full file
	(d) create the .so.debug file
	(c) create the (installable) .so file

for other builds, we simply use the same rule for (a) to create (c).

this stops the .so.debug rule from modifying the .so rule's target
and leading to mayhem.

see this thread for more details:
   http://mail-index.netbsd.org/tech-toolchain/2015/06/03/msg002616.html
2015-06-04 06:01:24 +00:00
christos
acb599fdb6 Strip the debug symbols via a temporary file, atomically replacing the full
random access archive to avoid races.
2015-06-02 23:00:25 +00:00
erh
6830ef879f PR toolchain/9618: add ".d" to MKDEP_SUFFIXES so the depend files are rebuilt
if any of their dependencies (i.e. the files they refer to) are changed.
This allows changes to transitive included headers to be handled properly.
2014-12-01 01:34:30 +00:00
mrg
26f35dd6b6 remove the build support for GCC 4.1, and any hacks i found for it.
there could still be more -- i only looked for lines matching
both "HAVE_GCC" and "4" as words (grep -w.)
2014-06-13 01:17:45 +00:00
pooka
d6b3d0da5a allow use with linkers that don't support --warn-shared-textrel
(Solaris, OpenBSD)
2014-04-24 00:14:59 +00:00
matt
c5ab5d969b Back changes from 1.349 on since the -Wl,-x bug has been fixed in binutils. 2014-04-11 16:51:43 +00:00
christos
2e21bd91e3 explain what's going on, add another kludge for -g 2014-04-11 15:56:09 +00:00
christos
cb8da48e03 Since the objcopy -x removes debugging symbols, delay that if we are building
debugging libraries and do the stripping with the debug symbol separation
step.
2014-04-09 19:23:09 +00:00
christos
eec8658016 change -x to OBJCOPYLIBFLAGS like everywhere else. 2014-04-09 16:29:08 +00:00
matt
5cb8c9ae75 Using -Wl,-x breaks build ARM BE8 shared libraries by striping the $a/$d/$t
symbols before the linker can use them.  Instead do ${OBJCOPY} -x ${.TARGET}
afterwards.
2014-04-04 05:10:15 +00:00
christos
199409cf03 let's see if the new dwarf library can handle dwarf 4 2014-03-09 18:00:51 +00:00
christos
aca5beab65 If we are compiling with -g and using gcc4.8 and dtrace downgrade
dwarf generation to version 2 for now.
2014-03-02 22:22:05 +00:00
mrg
e849bbac94 define EXTERNAL_GCC_SUBDIR based upon HAVE_GCC, for GCC >= 4.5,
and use it in the one place (bsd.lib.mk) it's used in share/mk.
2014-02-26 02:51:02 +00:00
apb
33295e8a08 Let MKARZERO default to the same value as MKREPRO, so callers
can set MKREPRO=yes and automatically get MKARZERO=yes.
2014-01-14 11:31:01 +00:00
matt
e3a958c021 Back out change for bsd.lib.mk which skips objcopy -x for BE ARM.
Change OBJCOPYLIBFLAGS to keep $a/$d/$t symbols on BE ARM.
2013-12-16 21:34:16 +00:00
matt
a49b15d8d8 Don't strip local symbols for earmv7*eb images since that will break linking. 2013-12-13 02:47:45 +00:00
christos
67ff86e929 change if HAVE_GCC is defined 2013-10-18 16:06:52 +00:00
joerg
aa6e9499ca Rename USE_LIBGCC to HAVE_LIBGCC and retry using it as flag on unwind.h. 2013-10-14 16:00:16 +00:00
joerg
d06922ddf4 Include compiler-rt and libunwind in libc for Clang/x86 builds. 2013-10-14 01:30:21 +00:00
joerg
36a6d19157 Handle dependency on libstdc++ / libc++ in bsd.lib.mk. 2013-09-12 17:14:20 +00:00
joerg
4d12bfcd15 Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
2013-09-12 15:36:14 +00:00
pooka
370de4e409 Enable opt-out from shlib mapfile creation. Not all linkers (namely
the solaris one) support such fancy features.

no default functional change
2013-07-19 11:43:18 +00:00
matt
d01d30fa5a When linking shared libraries, produce a map file. 2013-07-16 02:58:19 +00:00
riastradh
f85ea5612a Move addition of -g to CSHLIBFLAGS later in bsd.lib.mk.
It is now past any conditionals where its emptiness or nonemptiness can
influence the decision of what objects get built.

Fixes MKDEBUG=yes build on vax (PR 47700).
2013-04-22 22:16:14 +00:00
christos
247331174c Install shlibdir debug links 2013-04-11 01:27:47 +00:00