Commit graph

227 commits

Author SHA1 Message Date
Mark Johnston 59a9e2ca26 Automatically build with debug symbols when building with WITH_CTF.
Otherwise there's nothing for ctfconvert to do, and it ends up emitting an
error for each object file. Also remove some redundant checks from
bsd.prog.mk and bsd.lib.mk.

Differential Revision:	https://reviews.freebsd.org/D1111
Reviewed by:		imp
2014-11-06 22:46:40 +00:00
Baptiste Daroussin e82241aa78 Revert r273426 r273409
A solution that work with both new and old binutils should be investigated
2014-10-21 21:17:44 +00:00
Baptiste Daroussin 412013d7a8 older binutils does not know about --no-fatal-warnings 2014-10-21 21:09:54 +00:00
Baptiste Daroussin 9904471bf3 Do not make ld(1) warnings fatal anymore, binutils behaviour has changed over the
time and gnu.warnings.symbol are now being fatal preventing building world.

in the futur we want to investigate only making the gnu.warning.symbol non fatal

Reviewed by:	imp
2014-10-21 20:11:05 +00:00
Rui Paulo 9c851217b6 Make sure the DTrace header files are built before depend and before
the build starts.

This adds a new variable DHDRS that contains a list of all DTrace
header files.  Then, we use the beforedepend hook to make sure the
heaeder files are built.

Introduce a beforebuild dependency (from projects/bmake) based on
feedback from Simon J. Gerraty.  This lets us generate the header
files without running make depend.

Reviewed by:	sjg, imp
MFC after:	3 days
2014-08-13 01:27:51 +00:00
Baptiste Daroussin d029c3aa25 Rework privatelib/internallib
Make sure everything linking to a privatelib and/or an internallib does it directly
from the OBJDIR rather than DESTDIR.
Add src.libnames.mk so bsd.libnames.mk is not polluted by libraries not existsing
in final installation
Introduce the LD* variable which is what ld(1) is expecting (via LDADD) to link to
internal/privatelib
Directly link to the .so in case of private library to avoid having to complexify
LDFLAGS.

Phabric:	https://phabric.freebsd.org/D553
Reviewed by:	imp, emaste
2014-08-06 22:17:26 +00:00
Simon J. Gerraty 49217bc51e bsd.lib.mk does not add OBJS etc to CLEANFILES so does not automatically
get them flagged as .NOPATH.  This hurts people who don't use obj dirs.
Since its clean target seprate rm's for things, use NOPATH_FILES as list
to collect things that need .NOPATH.

bsd.obj.mk will add CLEANFILES to NOPATH_FILES and do the deed if needed.

Reviewed by: sbruno
2014-07-22 00:42:55 +00:00
Glen Barber 71b259d4f1 Merge r267837 from ^/projects/release-debugdist:
When building world when WITH_DEBUG_FILES is set,
  avoid building ar(1) archives with '-g'.

Tested on:	head@r267801
Reviewed by:	emaste, imp
Sponsored by:	The FreeBSD Foundation
2014-07-01 18:26:30 +00:00
Dag-Erling Smørgrav f1c8f60b88 Introduce RANLIBFLAGS to mirror ARFLAGS and add -D to both. This sets
all timestamps in static libraries to 0 so that consecutive builds
from the same source, even on different machines, produce identical
libraries.

MFC after:	3 weeks
2014-04-12 12:44:09 +00:00
Dag-Erling Smørgrav 2442cc585a Create a private library directory (LIBPRIVATEDIR) for libraries which
we don't want to expose but which can't or shouldn't be static.

To mark a library as private, define PRIVATELIB in its Makefile.  It
will be installed in LIBPRIVATEDIR, which is normally /usr/lib/private
(or /usr/lib32/private for 32-bit libraries on 64-bit platforms).

To indicate that a program or library depends on a private library,
define USEPRIVATELIB in its Makefile.  The correct version of
LIBPRIVATEDIR will be added to its run-time library search path.

Approved by:	re (blanket)
2013-09-08 09:40:23 +00:00
Jeremie Le Hen 726ffc602b Fix install from read-only obj dir when SHLIB_LDSCRIPT is used.
Reported by:    joeld
Tested by:      joeld
2013-06-16 16:29:23 +00:00
Ed Maste 42f8c5b580 Add a new knob WITH_DEBUG_FILES to control the building of standalone
debug files for userland programs and libraries.  The "-g" debug flag
is automatically applied when WITH_DEBUG_FILES is set.

The debug files are now named ${prog}.debug and ${shlib}.debug for
consistency with other systems and documentation.  In addition they are
installed under /usr/lib/debug, to simplify the process of installing
them if needed after a crash.  Users of bsd.{prog,lib}.mk outside of the
base system place the standalone debug files in a .debug subdirectory.
GDB automatically searches both of these directories for standalone
debug files.

Thanks to everyone who contributed changes, review, and testing during
development.
2013-06-07 21:40:02 +00:00
Jeremie Le Hen ce8341fcb3 Rework the comment I initially wrote when SHLIB_LDSCRIPT was introduced.
The build system is really intricate and I had a hard time to remind the
whole picture even when reading my own words.  This one will hopefully
be better.
2013-05-25 22:17:14 +00:00
Mark Johnston 22f3da672d Make sure that ${SHLIB_NAME}.debug and ${SHLIB_NAME}.symbols are always
deleted by a "make clean" when DEBUG_FLAGS is set.

Reported by:	gleb
Approved by:	emaste (co-mentor)
2013-03-28 04:13:52 +00:00
Ed Maste 0d1fce25cb Fix parallel build race with DEBUG_FLAGS
Reported by: Jan Beich on freebsd-current
Tested by: markj
2013-02-20 20:42:56 +00:00
Brooks Davis dda3ce5a63 Don't declare an dependency on _maninstall when LIBRARIES_ONLY is set.
It doesn't exist.
2013-01-24 15:55:24 +00:00
Brooks Davis 12dd8cb14c Replace all known uses of ln in the build process with appropriate
install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK
variables.

Sponsored by:	DARPA, AFRL
Reviewed by:	ian, ray, rpaulo
2013-01-21 22:40:39 +00:00
Brooks Davis afd9b4631f Add a new LIBRARIES_ONLY make variable to disable the build and install
of files other than the actual libraries.

Use LIBRARIES_ONLY to supress the inclusion of files in the lib32
distribution that are duplicates of files in base.

Sponsored by:	DARPA, AFRL
Reviewed by:	emaste
2013-01-17 17:27:10 +00:00
Mark Johnston 593c0b49f9 Explicitly specify that the beforelinking target depends on the
generated object files, ensuring that the beforelinking recipe won't be
executed until compilation has finished.

Also define SHLIB_NAME_FULL to denote ${SHLIB_NAME}.debug if
DEBUG_FILES is set and ${SHLIB_NAME} otherwise, which helps avoid
obfuscating the compilation and linking rules.

Reviewed by:	emaste
Approved by:	emaste (co-mentor)
2012-12-31 21:54:43 +00:00
Ed Maste facaa6ee9f No reason to install debug data with the schg flag 2012-12-18 21:13:03 +00:00
Ed Maste e97696b5ec Put shared library debug info into separate .symbols file
Sponsored by: ADARA Networks
2012-12-15 00:03:35 +00:00
Ed Maste 0d947ed19a Minor refactoring prior to .symbols file changes
- Combine .if x and .if !x using .else
- Separate out beforelinking dependency
- Add comments to clarify .if nesting

Sponsored by: ADARA Networks
2012-12-14 18:30:01 +00:00
Eitan Adler 37a6031461 Clean up hardcoded ar(1) flags in the tree to use the global ARFLAGS in
share/mk/sys.mk instead.

This is part of a medium term project to permit deterministic builds of
FreeBSD.

Submitted by:	Erik Cederstrand <erik@cederstrand.dk>
Reviewed by:	imp, toolchain@
Approved by:	cperciva
MFC after:	2 weeks
2012-12-06 01:31:25 +00:00
Dimitry Andric 85d4004625 Amend r227797 by also passing ${STATIC_CXXFLAGS} for the other supported
C++ file extensions.

MFC after:	3 days
2012-06-09 11:41:29 +00:00
Jeremie Le Hen 51a65f35df Introduce the ${SHLIB_LDSCRIPT} variable to have an ld(1) script
instead of a symlink for .so files.

Reviewed by:    kib, kan (previous version), dim
Approved by:    kib (mentor)
Silence from:   -hackers@
MFC after:	1 week
2012-05-07 09:00:30 +00:00
Konstantin Belousov bd4632e6ca Force linker error when created shared library contains a relocation
against text. Provide the override switch to turn off the strict
behaviour. Apparently, openssl libcrypto needs it due to assembler
code not being PIC.

Discussed with:	bf
MFC after:	2 weeks
2011-12-06 11:28:17 +00:00
Max Khon 83cb5bae96 - CTF knob is now implemented using common scheme: MK_CTF=yes/no is
defined based on WITH/WITHOUT_CTF settings, default is WITHOUT_CTF,
NO_CTF overrides WITH_CTF (used by Makefile.inc1)
- CTFCONVERT_CMD/NORMAL_CTFCONVERT are now defined to empty string
if make(1) can handle empty commands
2011-11-30 18:11:49 +00:00
Max Khon 78e7e3ecb5 - fix WITH_CTF when specified in /etc/src.conf [1]
- CTFCONVERT_CMD=... is a hack (should be defined to empty string instead):
make(1) should be taught to ignore empty commands silently in compat mode
(as it does in !compat mode, GNU make also silently ignores empty commands)
and to skip printing empty commands in !compat mode
- config(8) should generate ${NORMAL_CTFCONVERT} invocation without '@':
this will allow to simplify kern.pre.mk even more and lessen the number
of shell invocations during kernel build when CTF is turned off
- WITH_CTF can now be converted to usual MK_CTF=yes/no infrastructure

Pointy hat to:	fjoe [1]
2011-11-29 16:34:44 +00:00
Max Khon cd49c2e840 Conditionalize ctfconvert/ctfmerge runs on make level (.if/.endif) instead
of executing a shell on every object or executable/library file.

This shaves off more than 30,000 shell invocations during buildworld.
2011-11-29 08:38:47 +00:00
Dag-Erling Smørgrav 66f96aa5d4 Add CTF magic to the new .c.o rule.
MFC after:	3 weeks
2011-11-24 13:13:50 +00:00
Dag-Erling Smørgrav 2ba2959320 As threatened on -arch, add {SHARED,STATIC}_{C,CXX}FLAGS, which allow a
Makefile to specify different CFLAGS for shared and static libraries.

MFC after:	3 weeks
2011-11-21 16:35:57 +00:00
Dimitry Andric 58ff0f42ba Remove support for the Intel C Compiler from the build infrastructure.
This support has not worked for several years, and is not likely to work
again, unless Intel decides to release a native FreeBSD version of their
compiler. ;)
2011-04-19 18:09:21 +00:00
Dimitry Andric 6d67f69487 Remove libobjc and other Objective-C related components, as these are
extremely outdated, and not used by anything in the base system.

Silence from:	current@
2011-04-17 21:03:23 +00:00
Konstantin Belousov 5ada7d99af Introduce make variable ACFLAGS used to supply additional flags to
cc driver when compiling assembler source file that is preprocessed.
2011-01-07 14:32:29 +00:00
Rui Paulo c2c48445ba Check the existence of a 'beforelinking' target and make the resulting
program or library depend on that before doing the final linking. This
will be needed by DTrace.

Sponsored by:	The FreeBSD Foundation
2010-09-10 16:21:09 +00:00
Warner Losh 25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Rui Paulo 187278cadc For every instance of '.if ${CC} == "foo"' or '.if ${CC} != "foo"' in
Makefiles or *.mk files, use ${CC:T:Mfoo} instead, so only the basename
of the compiler command (excluding any arguments) is considered.

This allows you to use, for example, CC="/nondefault/path/clang -xxx",
and still have the various tests in bsd.*.mk identify your compiler as
clang correctly.

ICC if cases were also changed.

Submitted by:	Dimitry Andric <dimitry at andric.com>
2010-08-17 20:39:28 +00:00
Rui Paulo b4d22b2cb9 Add missing escape characthers.
Pointed out by:	b.f.
2010-07-30 15:25:57 +00:00
Rui Paulo 3a1134997b Fix previous commit: I forgot to include parenthesis.
Submitted by:	anonymous
2010-07-30 08:52:19 +00:00
Rui Paulo 8a5216d5d8 When building WITH_CTF=1, print the ctf executable that's going to be
run. This makes the 'ctfconvert' and 'ctfmerge' programs show up during
a build when compiling a kernel, a library or a program.

Sponsored by:	The FreeBSD Foundation
2010-07-29 16:30:27 +00:00
Alexander Leidinger 21edb039c6 WITH_CTF can now be specified in src.conf (not recommended, there
are some problems with static executables), make.conf (would also
affect ports which do not use GNU make and do not override the
compile targets) or in the kernel config (via "makeoptions
WITH_CTF=yes").

Additional (related) changes:
 - propagate WITH_CTF to module builds
 - do not add -g to the linker flags, it's a noop there anyway
   (at least according to the man page of ld)
 - do not add -g to CFLAGS unconditionally
   we need to have a look if it is really needed (IMO not) or if there
   is a way to add it only when WITH_CTF is used

Note: ctfconvert / ctfmerge lines will not appear in the build output,
to protect the innocent (those which do not build with WITH_CTF would
see the shell-test and may think WITH_CTF is used).

Reviewed by:	imp, jhb, scottl (earlier version)
Discussed on:	arch@
2010-04-02 06:55:31 +00:00
Stephane E. Potvin 424b4e66a9 Introduce two new flags PO_CFLAGS and PO_CXXFLAGS to make it possible
to have different flags when building profiled objects.

MFC after:	1 month
2010-01-22 14:05:48 +00:00
Alexander Kabaev 2286fe7635 Second attempt at eliminating .text relocations in shared libraries
compiled with stack protector.

Use libssp_nonshared library to pull __stack_chk_fail_local symbol into
each library that needs it instead of pulling it from libc. GCC
generates local calls to this function which result in absolute
relocations put into position-independent code segment, making dynamic
loader do extra work every time given shared library is being relocated
and making affected text pages non-shareable.

Reviewed by:        kib
Approved by:        re (kib)
2009-07-14 21:19:13 +00:00
John Birrell 770ac3b21f Add support for the Compact C Type (CTF) conversions throughout FreeBSD's
system makefiles.

Note that the CTF conversion defaults to off. We may choose to change this
default later if DTrace proves popular and people are prepared to wear
the compilation performance impact of compiling with debug symbols all the
time.

Setting NO_CTF in the make args or user environment turns off CTF conversion.
Even if we choose to default CTF generation to on later, we still need
NO_CTF so that the buildworld process can bootstrap the tools without
needlessly generating CTF data for temporary tools.

Setting WITH_CTF in the make args or user environment (and _NOT_ in
/etc/make.conf) is the only way to enable CTF data conversion. Nore that
this can't be implemented the same way that the WITH_ and WITHOUT_ stuff
is implemented throughout the buildworld because the CTF conversion needs
to work when building a simple object without a Makefile, using the
default rules in sys.mk.

Typing 'make test.o' with no makefile and just a source file test.c
should work. Also, typing 'make WITH_CTF=1 test.o without a makefile and
just a source file test.c should work and produce an object with a CTF
elf section. Typing 'make WITH_CTF=1 CFLAGS=-g test.o' without a makefile
and just a source file test.c should produce an object with both a CTF
elf section and the debug elf sections.

In the FreeBSD build where more .mk files are used than just sys.mk
which is included my make by default, the use of DEBUG_FLAGS is the
correct way to enable a debug build. The important thing to note here
is that it is the DEBUG_FLAGS setting that prevents libraries and
programs from being stripped on installation. So, for the addition of
CTF data conversion, setting DEBUG_FLAGS to contain -g, without NO_CTF,
will cause the ctfconvert and ctfmerge build programs to be executed
also with the -g arg so that debug symbols are retained rather than
being removed after the CTF data elf section has been added.

Add DTrace libraries to the list of libnames.
2008-05-22 01:14:43 +00:00
Alexander Kabaev 046f4eba8c Fix spelling mistake in comment. 2008-04-09 20:27:53 +00:00
Ruslan Ermilov 4f6d329f1e - Convert NO_INSTALLLIB option to a new syntax: makefiles should
test MK_INSTALLLIB, users can set WITHOUT_INSTALLLIB.  The old
  NO_INSTALLLIB is still supported as several makefiles set it.

- While here, fix an install when instructed not to install libs
  (usr.bin/lex/lib/Makefile).

PR:		bin/114200
Submitted by:	Henrik Brix Andersen
2007-10-20 19:01:50 +00:00
Ruslan Ermilov dc9f26d3c3 Style: remove redundant parentheses. 2007-05-21 09:01:23 +00:00
Daniel Eischen 00fb440c1a Enable symbol versioning by default. Use WITHOUT_SYMVER to disable it.
Warning, after symbol versioning is enabled, going back is not easy
(use WITHOUT_SYMVER at your own risk).

Change the default thread library to libthr.

There most likely still needs to be a version bump for at least the
thread libraries.  If necessary, this will happen later.
2007-05-13 14:12:40 +00:00
Alexander Kabaev 2da4e4706d Break out Version.map generation code from bsd.lib.mk into a
separate bsd.symver.mk file. Include bsd.symver.mk in bsd.lib.mk
to maintain the status quo.
2007-04-03 18:56:05 +00:00
Ruslan Ermilov 1340597def - Don't pass an empty ``NM='' to lorder(1) when NM is unset.
- Don't redundantly use "env".
- Protect NM value with quotes, just in case.
2006-10-25 09:43:38 +00:00