History log of /freebsd-current/Makefile.libcompat
Revision Date Author Comments
# 834f73d2 21-Aug-2023 John Baldwin <jhb@FreeBSD.org>

build{libcompat}: Pass UNIVERSE_TOOLCHAIN_PATH to the _lc_build-tools submake

This fixes make UNIVERSE_TOOLCHAIN=yes with libcompats.

Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D41535


# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# 8aaa1230 10-Aug-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Makefile.libcompat: Fix DTRACE variable

Back when Makefile.lib32 was turned into Makefile.libcompat, a typo was
introduced; it should have been LIBCOMPATDTRACE, but instead gained a
dollar sign in it as LIB$COMPATDTRACE (and with COMPATDTRACE not being
defined, was equivalent to ${LIB:U${DTRACE}}). This then meant it was
not converted to LIB${_LIBCOMPAT}DTRACE in 91d7edd549f5 ("Generalise
libcompat to be a list rather than a single option") and instead left
broken. Belatedly fix this long-standing seemingly-inconsequential bug.

Fixes: dba75e9fa5a9 ("Move Makefile.lib32 to Makefile.libcompat and generalize it.")


# 1c024976 01-Aug-2023 John Baldwin <jhb@FreeBSD.org>

Makefile.inc1: Enable requesting the universe toolchain.

make universe builds a cross toolchain under HOST_OBJTMP/tmp via the
universe-toolchain target. However, doing a plain 'make buildworld'
after a universe/tinderbox run (e.g. to reproduce a failure and test
the fix for it), will try to build a new cross toolchain under
OBJTMP/tmp which can be tedious. This commit adds a make variable
(UNIVERSE_TOOLCHAIN) which can be used similar to CROSS_TOOLCHAIN to
request an external toolchain. If this variable is set (value doesn't
matter), the the universe toolchain is used as an external toolchain.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D40777


# a1b67573 25-Jul-2023 Mike Karels <karels@FreeBSD.org>

arm64 lib32: enable building of lib32 on arm64

Enable LIB32 option on aarch64, defaulting to YES; it had defaulted
to "broken". Add required variables for how to compile lib32 on
arm. Use /usr/include/arm for armv7 (32-bit) headers, analogous to
/usr/include/i386 on amd64. Omit libomp from lib32; it is not
supported on armv7.

Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D40945


# 5d4f8df4 13-Jul-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Makefile.libcompat: Make quoting for CC/CXX/CPP more future-proof

bmake's :Q is for quoting outside of double quotes, but here is inside
double quotes, and as a result it ends up quoting characters that don't
have a special meaning inside double quotes. On the surface this would
seem harmless, but POSIX sh has a strange behaviour (differing from
outside double quotes) that, inside double quotes, a backslash before a
character that never has a special meaning inside double quotes is
passed through. As a result, should LIB${_LIBCOMPAT}CFLAGS contain
something like -DFOO\(x\)=x, we would form "... -DFOO\\\(x\\\)=x ...",
which would be parsed as -DFOO\\(x\\)=x, since the parentheses are never
special inside double quotes (but the backslash itself is), not the
original -DFOO\(x\)=x as intended.

Instead, construct the whole string as a bmake expression and use :Q on
that, without the manual double quotes around everything. Note that the
:L modifier lets you treat an expression like a variable expansion and
apply modifiers to it, i.e. ${expr:L:...} is the same as tmp=expr
${tmp:...} (in essence, ignoring possible differences due to deferred
substitution).

Improves: 537f945fc89f ("Makefile.libcompat: Quote CFLAGS and CXXFLAGS for sub-make")


# 0a5e35a7 13-Jul-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Makefile.libcompat: Be consistent about not installing includes

Currently we only pass MK_INCLUDES=no for distribute and install, since
it's only in LIB${_LIBCOMPAT}IMAKE, which means that we enable includes
during libraries and thus install includes into worldtmp, despite it
being shared these days across native and libcompats. This also means
we're at risk of having headers needed for building against a libcompat
that don't get installed to the system, but do end up being installed to
worldtmp. In particular, lib/msun has different fenv.h for aarch64 and
arm, so aarch64 will need arm's copy when it grows lib32 support, and
this would be installed to worldtmp, but not to the system, meaning any
programs that use fenv.h wouldn't be able to be built.

Instead, be consistent, and don't install includes at all during any of
the libcompat phases, so that we can detect these issues and ensure any
needed headers are installed for both worldtmp and the system.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D41030


# 537f945f 09-Jul-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Makefile.libcompat: Quote CFLAGS and CXXFLAGS for sub-make

Currently none of the words in these require quoting, but a future
commit will add words that do, thus we should make sure to quote each
word so the shell doesn't mangle them before calling the sub-make.

(Note that :@var@expr@ is the bmake syntax for map, replacing each word
with expr's evaluation, with var containing the input word)

Reviewed by: emaste, brooks, jhb
Differential Revision: https://reviews.freebsd.org/D40921


# 91d7edd5 27-Jun-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Generalise libcompat to be a list rather than a single option

Whilst the kernel can support any number of COMPAT_FOO, world can only
build a single libfoo. Upstream this isn't such an issue, since the only
option is lib32 anyway, but downstreams, such as CheriBSD, may wish to
support multiple at the same time. Thus, adjust the top-level Makefiles
to turn _LIBCOMPAT into a _LIBCOMPATS list that gets iterated over, and
adjust bsd.compat.mk to support this use-case.

For the normal NEED_COMPAT/WANT_COMPAT case, LIBCOMPATFOO remain set and
refer to the requested compat's, preserving the current interface. For
the top-level Makefiles those variables are no longer set (since there
is no longer "the" compat) and only the per-compat ones are available.

Reviewed by: brooks, jhb, imp
Differential Revision: https://reviews.freebsd.org/D40571


# 10afc5ea 27-Jun-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Makefile.libcompat: Handle MK_FOO varying for native and compat arches

Currently Makefile.libcompat queries a few MK_FOO variables to determine
what is being built. However, it is plausible (and indeed, downstream
in CheriBSD, this is the case) that these may vary between the native
and the compat architecture. In order to correctly determine their
values for the compat architecture, we need to defer their evaluation
until we are in the compat sub-make where src.opts.mk will give us the
right value for the compat MACHINE_ARCH.

Reviewed by: brooks, jhb, imp
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D40570


# 5ed85151 27-Jun-2023 Jessica Clarke <jrtc27@FreeBSD.org>

Makefile.libcompat: Remove unused _LC_INCDIRS

This is no longer referenced as of commit 724123b9f4d3 ("libcompat: Use
WORLDTMP sysroot").

Reviewed by: brooks, jhb, imp
Differential Revision: https://reviews.freebsd.org/D40569


# 227f47ce 16-Nov-2022 Ed Maste <emaste@FreeBSD.org>

libcompat: avoid installing include files twice

Previously some headers were getting installed twice, once as expected
and then a second time as part of the compat32 library stage.

Makefile.libcompat sets -DLIBRARIES_ONLY for the install make invocation
which causes bsd.lib.mk to skip headers. However some headers are
handled via bsd.prog.mk, which does not use LIBRARIES_ONLY. Explicitly
set MK_INCLUDES=no.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37413


# ac175bd3 11-Aug-2022 Alex Richardson <arichardson@FreeBSD.org>

Install working pkgconfig .pc files for compat libraries

The default ones are install them to /usr/libdata/pkgconfig, and we can't
use this path for compat libraries, so we use /usr/lib<suffix>/pkgconfigi here.

Test Plan: grep -rn libdir= ./usr/lib32/pkgconfig/*.pc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34939


# 724123b9 01-Jul-2022 Brooks Davis <brooks@FreeBSD.org>

libcompat: Use WORLDTMP sysroot

Now that -m32 is fixed, just install libs in ${WORLDTMP}/lib/lib32
and use the installed headers.

Reviewed by: imp, jhb
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D34697


# 03f6e182 02-Feb-2022 Warner Losh <imp@FreeBSD.org>

Makefile.libcompat: Sort

Sort MK_BOOT before MK_CTF and remove now-useless NO_LINT while I'm
here.

Suggested by: brooks, emaste
Sponsored by: Netflix


# 03475562 02-Feb-2022 Warner Losh <imp@FreeBSD.org>

stand: Fix kboot issue on powerpc64 with MK_LIB32=yes

When MK_LIB32 is true, we descend into stand for make includes, make
clean, etc. We shouldn't do this, so set MK_BOOT=no when we're building
includes.

Fixes: 6497250f6f7f
PR: 261497
Sponsored by: Netflix
Reviewed by: emaste, brooks (he suggested this)
Differential Revision: https://reviews.freebsd.org/D34141


# aada8c47 09-Dec-2021 Warner Losh <imp@FreeBSD.org>

libcompat: Remove MIPS from list of compat libraries

Sponsored by: Netflix


# cc46927f 04-Oct-2021 Baptiste Daroussin <bapt@FreeBSD.org>

ncurses: fix libcompat (lib32 for example) building


# 61ed578e 04-Aug-2021 Mitchell Horne <mhorne@FreeBSD.org>

Prefer MK_SSP=no to SSP_CFLAGS=

It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when
$MK_SSP != "no".

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31401


# bcd2f41f 04-Aug-2021 Mitchell Horne <mhorne@FreeBSD.org>

mk: format some option lists

Alphabetize and give each option its own line, ahead of making another
change to these lists. This makes future diffs easier to read.

Reviewed by: imp, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31399


# 7bc797e3 02-Aug-2021 Alex Richardson <arichardson@FreeBSD.org>

Add build system support for ASAN+UBSAN instrumentation

This adds two new options WITH_ASAN/WITH_UBSAN that can be set to
enable instrumentation of all binaries with AddressSanitizer and/or
UndefinedBehaviourSanitizer. This current patch is almost sufficient
to get a complete buildworld with sanitizer instrumentation but in
order to actually build and boot a system it depends on a few more
follow-up commits.

Reviewed By: brooks, kib, markj
Differential Revision: https://reviews.freebsd.org/D31043


# 99feb137 01-Aug-2021 Wolfram Schneider <wosch@FreeBSD.org>

`make buildworld' with time logging for each stage

PR: 257141
Reviewed by: sjg,emaste
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D31154


# 689c7e79 31-May-2021 Mitchell Horne <mhorne@FreeBSD.org>

libpmc: always generate libpmc_events.c

The jevents build tool will create an empty table if it doesn't find any
events, so we can remove the extra $MACHINE_CPUARCH checks.

Reviewed by: gnn, ray, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30531


# 8537f162 07-Jan-2021 Baptiste Daroussin <bapt@FreeBSD.org>

libcompat: remove redundant path for ncurses

Reported by: kevans


# 7fa2f2a6 06-Jan-2021 Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>

Rename NO_WERROR -> MK_WERROR=no

As suggested in D27598. This also supports MK_WERROR.clang=no and
MK_WERROR.gcc=no to support the existing NO_WERROR.<compiler> uses.

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D27601


# 94ffff68 06-Jan-2021 Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>

Stop passing MK_WARNS=no for bootstrap tools

I got annoyed by the number of warnings that the CheriBSD build was
emitting. It turns out that we are emitting lots of warnings during
bootstrap because bootstrap tools are built with the default compiler
flags and ignore the warnings flags that are set in bsd.sys.mk.

Looking at git blame, it appears that MK_WARNS=no has been passed since
rS112869, replacing the -DNO_WERROR option that was added in rS87775.

This commit changes MK_WARNS=no back to -DNO_WERROR. We need to pass
-DNO_WERROR, since the system compiler might have new warnings that we
don't know about yet, and we shouldn't fail the build in that case.

Reviewed By: imp, brooks
Differential Revision: https://reviews.freebsd.org/D27598


# 821aa63a 04-Jan-2021 Baptiste Daroussin <bapt@FreeBSD.org>

ncurses: only keep the version with widechar support

Only keep the widechar version of ncurses as libncursesw.so.9

Keep the old name to avoid breaking the ABI compatibility (the non
widechar version libncurses.so.9 is not binary compatible with
libncursesw.so.9) since all ports and base are already only linking
against the widechar version we can simply remove libncurses.so.9

Since the .9 version only lived in the dev branch and never ended in a
release, it is simply removed and not added to any binary compat
package.

Add symlinks to keep build time compatibility for anyone linking against
-lncurses


# 7eb9f755 08-Oct-2020 Warner Losh <imp@FreeBSD.org>

Race in 32-bit fixed

Use install insteald of install.sh for 32-bit builds to fight races there.

Reviewed by: markj


# 75766799 07-Sep-2020 Ed Maste <emaste@FreeBSD.org>

Add WITH_/WITHOUT_CLEAN option to replace NO_CLEAN

This allows use of the standard src.conf configuration for controlling
whether the tree is cleaned before build or not. The default is still
to clean.

Setting either NOCLEAN or NO_CLEAN will mention the new src.conf option.
NOCLEAN remains a .warning, while for now NO_CLEAN is .info.

Reviewed by: bdrewery (earlier version)
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22762


# eb61f7bd 26-Mar-2020 Emmanuel Vadot <manu@FreeBSD.org>

Stop building libl and liby

Those libs aren't needed anymore so stop building them for the bootstrap tools
or the compat libs.

Reviewed by: bapt, emaste
X-Differential Revision: D24171


# a4330302 07-Nov-2019 Brooks Davis <brooks@FreeBSD.org>

libcompat: build 32-bit rtld and ldd as part of "everything"

Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included
directly so MD paths in Makefiles work. In the process centralize
setting them in LIBCOMPATWMAKEENV.

Alter .PATH and CFLAGS settings in work when the Makefile is included.

While here only support LIB32 on supported platforms rather than always
enabling it and requiring users of MK_LIB32 to filter based
TARGET/MACHINE_ARCH.

The net effect of this change is to make Makefile.libcompat only build
compatability libraries.

Changes relative to r354449:

Correct detection of the compiler type when bsd.compat.mk is used
outside Makefile.libcompat. Previously it always matched the clang
case.

Set LDFLAGS including the linker emulation for mips where -m32 seems to
be insufficent.

Reviewed by: imp, kib (origional version in r354449)
Obtained from: CheriBSD (conceptually)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22251


# ccad77fe 07-Nov-2019 Brooks Davis <brooks@FreeBSD.org>

Revert r354449: libcompat: build 32-bit rtld and ldd as part of "everything"

Additional testing is required..


# 36712a94 07-Nov-2019 Brooks Davis <brooks@FreeBSD.org>

libcompat: build 32-bit rtld and ldd as part of "everything"

Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included
directly so MD paths in Makefiles work. In the process centralize
setting them in LIBCOMPATWMAKEENV.

Alter .PATH and CFLAGS settings in work when the Makefile is included.

While here only support LIB32 on supported platforms rather than always
enabling it and requiring users of MK_LIB32 to filter based
TARGET/MACHINE_ARCH.

The net effect of this change is to make Makefile.libcompat only build
compatability libraries.

Reviewed by: imp, kib
Obtained from: CheriBSD (conceptually)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22251


# 5dab1313 15-Oct-2019 Brooks Davis <brooks@FreeBSD.org>

Build compat libraries before "everything".

This is required for us to link programs against compat versions of
libraries.

Reviewed by: bdrewery, jhb
Sponsored by: DARPA, AFRL


# bbcf7edd 15-Oct-2019 Brooks Davis <brooks@FreeBSD.org>

Move the per-ARCH definitions to bsd.compat.mk.

This is the first step if refactoring the definitions to allow programs
to be selectively linked against libcompat libraries.

Reviewed by: bdrewery
Sponsored by: DARPA, AFRL


# 571fc82c 11-Oct-2019 Brooks Davis <brooks@FreeBSD.org>

Centralize adding OBJCOPY=${XOBJCOPY} to LIB32WMAKEFLAGS.

Reviewed by: emaste, imp
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21983


# 78aee653 25-Jul-2019 Ed Maste <emaste@FreeBSD.org>

libsysdecode: use the proper include directory

Reported by: cy
Reviewed by: lwhsu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21068


# 99c2d8c2 25-Jul-2019 Li-Wen Hsu <lwhsu@FreeBSD.org>

Workaround the build failure on platforms have lib32 after r350301

Error message:

make[5]: make[5]: don't know how to make /usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/sys/netinet/in.h. Stop

make[5]: stopped in /usr/src/lib/libsysdecode

Sponsored by: The FreeBSD Foundation


# 89ebdc94 29-Jun-2019 Tijl Coosemans <tijl@FreeBSD.org>

Build lib32 libl. The library is built from usr.bin/lex/lib. It would be
better to move this directory to lib/libl, but this requires more extensive
changes to Makefile.inc1. This simple fix can be MFCed quickly.

PR: 238874
Reviewed by: imp
MFC after: 3 days


# 23d772ee 12-Nov-2018 Brooks Davis <brooks@FreeBSD.org>

Use ...-freebsd13.0 in -target strings.

Reported by: Mark Millard


# 01b7ad04 03-Nov-2018 Ed Maste <emaste@FreeBSD.org>

libcompat: disable retpoline when building build tools

These are built with the host toolchain which may not support retpoline.
While here, move the MK_ overrides to a separate line and sort them
alphabetically to support future changes.

MFC with: r339511
Sponsored by: The FreeBSD Foundation


# a00cd954 23-Aug-2018 Alex Richardson <arichardson@FreeBSD.org>

Fix non-FreeBSD host lib32 build for TARGET=amd64

When building on non-FreeBSD systems we need to pass an explicit target
triple to clang otherwise it will attempt to build with the host triple.
This also has advantages when building on a FreeBSD host: we now tell
clang that we are targeting at least FreeBSD 12.0 instead of an older
version so it can enable newer features.

Reviewed By: brooks (mentor)
Approved By: jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D16842


# 52f9bacb 03-Aug-2018 John Baldwin <jhb@FreeBSD.org>

Install the 32-bit compat sanitizer libraries.

The lib32 build was already building the i386 version of
the clang sanitizers (libclang_rt) but they were not being
installed. This enables the installation.

MK_TOOLCHAIN=no was originally added to the install make
environment to disable includes so that NO_INCS could be
removed. The MK_TOOLCHAIN in bsd.incs.mk was subsequently
renamed to MK_INCLUDES, but bsd.lib.mk doesn't even include
bsd.incs.mk when LIBRARIES_ONLY is defined which the install
make environment for compat libs now defines. However,
setting MK_TOOLCHAIN=no forced MK_CLANG=no which disabled
libclang_rt during the install32 phase. Remove MK_TOOLCHAIN=no
since LIBRARIES_ONLY is now sufficient.

Since the libcompat environment overrides both LIBDIR and
SHLIBDIR, libclang_rt/Makefile.inc has to set both variables
to force the libraries to be installed to the location
expected by the compiler.

Reviewed by: bdrewery, dim
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D16574


# 0d849865 30-Jul-2018 Ed Maste <emaste@FreeBSD.org>

Makefile.libcompat: correctly append to make variable

Reported by: hselasky
Pointy hat to: emaste


# ad91146c 30-Jul-2018 Ed Maste <emaste@FreeBSD.org>

Makefile.libcompat: use one variable assignment per line

This makes it easier to carry or merge patches that remove gnu/
components.


# 55a5b46a 29-Jun-2018 Alex Richardson <arichardson@FreeBSD.org>

Don't change directory owner to root when building with -DNO_ROOT

Currently the mtree calls in Makefile.inc1 all change the directory owner
to match the spec file. However, we should not be doing this during
distributeworld if -DNO_ROOT is passed. Additionally, when creating the
WORLDTMP directory hierachy there is no need to change the owner to root so
we now always pass the -W flag when populating WORLDTMP.

This is also required for building FreeBSD on Linux/Mac since the required
groups/users will not exist there which is how I discovered this issue.

Reviewed By: emaste, bdrewery, imp
Approved By: brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D14185


# 151578dc 28-Jun-2018 John Baldwin <jhb@FreeBSD.org>

Remove the various build flag hacks for GCC cross-compile.

The xtoolchain GCC packages have not required these flags since ports
commits r465416 and r466701. The in-tree GCC 4.2.1 has also been patched
in r335716 and r335717 to correctly honor --sysroot when looking for
includes and libraries.

Reviewed by: bdrewery
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D16055


# 6e6be2bb 20-Jun-2018 Bryan Drewery <bdrewery@FreeBSD.org>

Reduce exec and fstat overhead for non-build targets.

This is mostly targetting 'make showconfig' and 'make test-system-*' for
the benefit of makeman and universe-one-clang work.

Sponsored by: Dell EMC


# c4273800 15-Jun-2018 Bryan Drewery <bdrewery@FreeBSD.org>

lib32: Fix lib/libpmc/pmu-events files ending up in source directory.

This could happen with either WITHOUT_AUTO_OBJ=yes or MAKELEVEL>0 for
the initial 'make buildworld' command.

This now ensures that build-tools targets have 'make obj' ran if needed.

This is especially problematic for pmu-events since it is not directly
connected in the build. Normally the 'make includes' call right before
this implicitly creates the objdir with a 'make obj' already but
misses pmu-events because it is disconnected from lib/libpmc. Fixing that
would make this new 'make obj' pointless but it is being added to avoid
this problem in the future should another tool be connected like this.

Reported by: rgrimes, kib, kevans
Sponsored by: Dell EMC


# 127b666c 15-Jun-2018 Bryan Drewery <bdrewery@FreeBSD.org>

libcompat: Only build libmagic build tool if MK_FILE is yes.

Sponsored by: Dell EMC


# 6f1f2b19 15-Jun-2018 Bryan Drewery <bdrewery@FreeBSD.org>

Only build jevents if MK_PMC is yes and only for amd64 in libcompat.

Sponsored by: Dell EMC


# 7d1c2b74 31-May-2018 Matt Macy <mmacy@FreeBSD.org>

libpmc/pmu: enable for i386 as well


# 1c0cac23 24-Jan-2018 Bryan Drewery <bdrewery@FreeBSD.org>

X_COMPILER_* may not be defined.

Sponsored by: Dell EMC


# a1554bba 15-Jan-2018 John Baldwin <jhb@FreeBSD.org>

Check for GCC first rather than clang in the MIPS lib32 rules.

This works around a bug with X_COMPILER_TYPE and permits mips64 to build
again with in-tree gcc as well as clang and external gcc.

Sponsored by: DARPA / AFRL


# 8d286bb9 11-Jan-2018 John Baldwin <jhb@FreeBSD.org>

Allow MIPS lib32 to build with clang.

Don't try to set -march as clang doesn't permit use of the O32 ABI
with newer CPU microarchitectures like 'mips3'. In addition, clang
doesn't permit the O32 ABI with the default N64 target, so use an
explicit O32 -target for clang.

Sponsored by: DARPA / AFRL


# 996e4759 04-Nov-2017 Bryan Drewery <bdrewery@FreeBSD.org>

Fix nested MAKEOBJDIRPREFIX breaking various release/buildworld/toolchain targets.

This problem was caused by r325329 and r325350.

For the release(7) targets, some will run mm-mtree.sh which itself runs make
with a MAKEOBJDIRPREFIX. The execution of that script leaks OBJROOT,
MAKEOBJDIR, and MAKELEVEL=1 in the environment. This causes the mm-mtree makes
to not do some basic setup of OBJROOT and only use this special
MAKEOBJDIRPREFIX case which fails to empty out MAKEOBJDIRPREFIX for further
nested makes, such as a tree walk. If that tree walk sets OBJROOT/OBJTOP such
as r325329 is doing, then the wrong OBJDIRs end up being used due to the
unemptied MAKEOBJDIRPREFIX being preferred over the proper MAKEOBJDIR.

Pointyhat to: bdrewery
Sponsored by: Dell EMC Isilon


# 1031b94f 04-Nov-2017 Bryan Drewery <bdrewery@FreeBSD.org>

Set OBJROOT/OBJTOP as make arguments. Missed in r325329.

Sponsored by: Dell EMC Isilon


# 4dc89c4d 02-Nov-2017 Bryan Drewery <bdrewery@FreeBSD.org>

Reduce MAKEOBJDIRPREFIX path spam by specifying a direct objdir to use.

Sponsored by: Dell EMC Isilon


# dfa09989 01-Nov-2017 Bryan Drewery <bdrewery@FreeBSD.org>

Add option UNIFIED_OBJDIR, on by default, which moves the default build OBJDIR.

This changes the build OBJDIR from the older style of /usr/obj/<srcdir> for
native builds, and /usr/obj/<target>.<target_arch>/<srcdir> for cross builds to
a new simpler format of /usr/obj/<srcdir>/<target>.<target_arch>. This
new format is used regardless of cross or native build. It allows
easier management of multiple source tree object directories.

The UNIFIED_OBJDIR option will be removed and its feature made permanent
for the 12.0 release.

Relnotes: yes (don't note UNIFIED_OBJDIR option since it will be removed)
Prior work: D3711 D874
Reviewed by: gjb, sjg
Discussed at: https://lists.freebsd.org/pipermail/freebsd-arch/2016-May/017805.html
Discussed with: emaste
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12840


# 2aba4f29 28-Oct-2017 Bryan Drewery <bdrewery@FreeBSD.org>

lib32/libsoft: Store object files in a more consistent structure.

Having objects in world32 and a sysroot in lib32 was confusing and
inconsistent with the normal build. Now objects are stored in
obj-lib32 (or obj-libsoft) and the sysroot (analagous to WORLDTMP)
is stored in obj-lib32/tmp.

Sponsored by: Dell EMC Isilon


# 67d2f51a 28-Oct-2017 Bryan Drewery <bdrewery@FreeBSD.org>

Move some LIBCOMPAT tmpdir logic setup to its own build target.

Its own build target was already handling mtree extractions
just as _worldtmp did, so the other cleaning of the
tmpdir makes sense here as well.

Sponsored by: Dell EMC Isilon


# 0b972ac9 05-Oct-2017 Warner Losh <imp@FreeBSD.org>

Support armv7 builds for userland

Make armv7 as a new MACHINE_ARCH.

Copy all the places we do armv6 and add armv7 as basically an
alias. clang appears to generate code for armv7 by default. armv7 hard
float isn't supported by the the in-tree gcc, so it hasn't been
updated to have a new default.

Support armv7 as a new valid MACHINE_ARCH (and by extension
TARGET_ARCH).

Add armv7 to the universe build.

Differential Revision: https://reviews.freebsd.org/D12010


# 90d1f60e 30-Sep-2017 Enji Cooper <ngie@FreeBSD.org>

Adjust r322633 to only apply to libexec/rtld-elf, and not usr.bin/ldd,
when running build32/install32

This unbreaks installing usr.bin/ldd as ldd32 when NO_RTLD is defined.

MFC after: 1 week
MFC with: r322633


# 4ff30397 17-Aug-2017 Enji Cooper <ngie@FreeBSD.org>

Honor NO_RTLD for rtld-elf, similar to what's done in libexec/Makefile, with
libexec/rtld-elf/... for MK_{LIB32,LIBSOFT}.

MFC after: 1 week


# bf9c216f 15-Aug-2017 Enji Cooper <ngie@FreeBSD.org>

Disable MK_COVERAGE with LIB32, LIBSOFT, etc

Baking coverage into binaries won't work because the architecture is
baked into the tool chain. Plus enabling it here doesn't really make
a whole lot of sense.


# 8422e09e 07-Aug-2017 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r321684 (Don't use libc++ when cross-building for gcc
arches), and handle two more cases where libc++ includes could be
incorrectly enabled, in case the host compiler is clang 5.0.0, and the
target (cross) compiler is gcc 4.2.1.

Noted by: bdrewery
MFC after: 3 days
X-MFC-With: 321684


# 35fb812a 19-Jun-2017 Bryan Drewery <bdrewery@FreeBSD.org>

buildworld: Define SYSROOT to WORLDTMP.

This is to allow downstream Makefiles to know for sure they are building
against a sysroot rather than only depending on ${DESTDIR} or other
assumptions.

This also exports it into buildenv.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon


# 6d75a7a8 09-May-2017 Bryan Drewery <bdrewery@FreeBSD.org>

Support skipping 'make obj' tree-walk.

This is part of a larger effort for WITH_AUTO_OBJ and a WORLDFAST
option.

Sponsored by: Dell EMC Isilon


# dbbb03c2 06-Apr-2017 Bryan Drewery <bdrewery@FreeBSD.org>

META_MODE: Fix build-tools still sometimes rebuilding during target build.

In a cross-build, the build-tools are native host binaries. We do not
want to rebuild them when building for the target. Bmake previously
did not support checking .NOMETA on an existing target, so .NOMETA_CMP
was used here. However, .NOMETA_CMP still triggers meta mode conditions
if the number of commands or the command changes. In r312467 the paths
to build ncurses files were modified and thus triggered meta mode to
rebuild the build tools (make_keys, make_hash) in ncurses during the
target build. Bmake 20160604 committed in r301462 changed .NOMETA to
also skip meta mode logic for an existing .meta file as well, thus it
is now the proper fix here.

I explored moving the build-tools output to WORLDTMP/tools with
relatively good success, but have concerns that doing so would be
problematic for downstream vendors who use LOCAL_TOOL_DIRS and
expect the tools to be in current OBJDIR for the target. It also
adds more complexity into finding the tools during target build
and handling of where they are for rescue/rescue and
mkcsmapper_static/mkesdb_static which should really not be connected in
build-tools anyway.

MFC after: 2 weeks
Reported by: many
Sponsored by: Dell EMC Isilon


# bdb691d4 26-Jan-2017 Ed Maste <emaste@FreeBSD.org>

Use cross-NM (XNM) in compat32 build

An attempt to build mips64 using external toolchain failed as it tried
to use the host amd64 nm.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 69b4d461 06-Jan-2017 John Baldwin <jhb@FreeBSD.org>

Enable /usr/lib32 for o32 binaries on mips64.

Build and install an o32 set of libraries on mips64 suitable for
running o32 binaries via COMPAT_FREEBSD32. Enable COMPAT_FREEBSD32 in
MALTA64.

Reviewed by: jmallett, imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D9032


# 452a3101 06-Jan-2017 John Baldwin <jhb@FreeBSD.org>

Set -m32 in MD LIB32CPUCFLAGS rather than MI LIB32CFLAGS.

Both amd64 and powerpc64 use -m32 to compile 32-bit binaries, but not
all platforms follow this convention. Move the -m32 compile flag into
the per-architecture flags to accomodate other architectures.

Sponsored by: DARPA / AFRL


# 646a9763 25-Dec-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Fix build of lib32 libraries for amd64 and powerpc64 with cross toolchain


# 4d611b2b 23-Aug-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Fix in-tree GCC builds after r304681.

There were a few issues.
- In-tree GCC won't have X_COMPILER_TYPE defined but will have
WANT_COMPILER_TYPE==gcc set from the SYSTEM_COMPILER logic that can
be used. Make the clang check specific to clang as well to ensure
-target doesn't leak into a GCC build.
- When using a cross-compiler GCC (with a default sysroot or arch) and also
passing --sysroot, it basically forgets all internal paths for
libraries. We've already worked around this quite a bit for
the external toolchains. Now for the in-tree bootstrap cross-compiler
GCC, also pass in the needed -B${WORLDTMP}/usr/lib to find the crt
object files, but also -isystem and -L to fix the paths. This creates
quite a spammy build log, but it is clear and still achieves the goals
and stays consistent between internal and external build flags.
Reducing the spam by using the '=' prefix feature will help and be
done later.

MFC after: 3 days
X-MFC-With: r304681
Reported by: bz
Pointyhat to: bdrewery
Sponsored by: EMC / Isilon Storage Division


# 73371266 24-Jul-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Don't disable binutils/elftoolchain bootstrapping with external compiler.

This was a regression from r300349.

Setting MK_CROSS_COMPILER=no forces the compiler bootstraping *and* the
binutils/elftoolchain bootstrapping to be disabled in share/mk/src.opts.mk.
The only intent with using an external compiler is to disable bootstrapping of
the compiler. The binutils/elftoolchain bootstrapping must still occur unless
XAS is set. This did not affect WITH_SYSTEM_COMPILER.

Now that setting an external compiler sets both MK_CLANG_BOOTSTRAP and
MK_GCC_BOOTSTRAP to no, and MK_CROSS_COMPILER does the same via
share/mk/src/opts.mk, remove redundant logic that checks for
MK_CROSS_COMPILER. It will not always be true now that MK_CROSS_COMPILER==no
when an external compiler is used and --sysroot/-target is needed.

Reported by: sbruno
Pointyhat to: bdrewery
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division


# 48413367 28-Jun-2016 Bryan Drewery <bdrewery@FreeBSD.org>

WITH_SYSTEM_COMPILER: Avoid using GCC4.8+ logic on native GCC4.2 platforms.

As the XXX notes, these should really be checking MK_GNUCXX since there is
already a version check in share/mk/src.opts.mk to disable it. Fixing that
here is more complex though. This could also be using X_COMPILER_FEATURES
but uses X_COMPILER_VERSION to keep in sync with the src.opts.mk logic.

Tested by: andreast
Sponsored by: EMC / Isilon Storage Division
Approved by: re (gjb)


# 07394091 15-Jun-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Fix native powerpc64 build of lib32 with in-tree GCC.

- This was broken by r300350 and r300885.
- Add some comments around the external GCC logic since it is spread out
and in need of some cleanup.
- The problem was that X_COMPILER_TYPE is always defined from CC->XCC's
default, so if /usr/bin/cc is GCC (as it is on native powerpc64) then
X_COMPILER_TYPE was getting GCC and triggering the external logic in
Makefile.libcompat. It was intended to always provide -isystem with
GCC since --sysroot is used into the lib32 sysroot which won't modify
the header path without the -isystem. The use of the libc++/std=c++11
override was only intended to be used for external compilers though
(more accurately GCC 4.8+ but that's a separate assumption to
cleanup). Apply the same logic from Makefile.inc1 to Makefile.libcompat
to only add the libc++ override when needed for external compilers.

Pointyhat to: bdrewery
Tested with: native ppc64 (swills), universe, ppc64 xtoolchain,
amd64 xtoolchain, sparc64 cross-build of ppc64 (host GCC 4.2)
Reported by: andreast, swills
Approved by: re (gjb)
Sponsored by: EMC / Isilon Storage Division


# dfaedbb2 09-Jun-2016 Ed Maste <emaste@FreeBSD.org>

Use -L to specify compat32 library paths instead of -Y

-Y is an uncommon linker option that is rather similar to -L. In
discussion with Peter it seems early amd64 development might have
required the -Y-specific behaviour, but it is no longer necessary.

Switch to -L which is more widely supported and much more commonly
used, to make it easier to link the FreeBSD base system with linkers
other than ld.bfd.

Submitted by: Rafael Ávila de Espíndola
Differential Revision: https://reviews.freebsd.org/D6681


# 76c5029c 29-May-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Libcompat: Swap CXX/CFLAGS.

This is the same as done for the native build in r300770 to ensure that
the libc++ build reads from SYSROOT/usr/include/c++/v1 before reading
from SYSROOT/usr/include.


# f661dbee 29-May-2016 Bryan Drewery <bdrewery@FreeBSD.org>

GCC External: Revert r300886, r300904, r300917, r300918

The fix in r300873 is mostly enough. A fix for lib32 will be
committed.separately.


# 83e0f7db 28-May-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Libcompat: Set build tools in environment rather than make overrides.

This allows the CXX hack in r300917 for external GCC to work for
the lib32 build. It is also the same pattern as the native
build uses by adding the tools into CROSSENV for external
toolchain, rather than make overrides.

Sponsored by: EMC / Isilon Storage Division


# ce00342b 27-May-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Move external GCC compiler hacks to bsd.sys.mk.

This allows respecting -nostdinc, -nostdinc++ and -nostdlib before
making the decision to add in -isystem, etc. The -isystem flags
are problematic for building lib/libc++ and lib/libcxxrt which wants
to only use its own headers.

More information the need of these flags can be found at
https://gcc.gnu.org/ml/gcc/2016-03/msg00219.html

This also reverts r300873.

Sponsored by: EMC / Isilon Storage Division


# 47873c16 27-May-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Libcompat: Only pass -isystem =/usr/include for external GCC.

This is the same as the main build logic. GCC with a cross-compiler
requires using -isystem to =/usr/include to get the search order
correct.

Reported by: dim, asomers
Sponsored by: EMC / Isilon Storage Division


# 83f29075 15-Apr-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Set CPP from XCPP for the libcompat build.

Submitted by: Mark Millard <markmi@dsl-only.net>


# d1dd034d 14-Apr-2016 Bryan Drewery <bdrewery@FreeBSD.org>

META_MODE: Don't rebuild build-tools targets during normal build.

This avoids 'build command changed' due to CFLAGS/CC changes during the
normal build. Without this the build-tools targets end up rebuilding
for the *target* rather than keeping the native versions built in
build-tools.

Sponsored by: EMC / Isilon Storage Division


# 91da7698 05-Apr-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Remove leftover _LDSCRIPTROOT missed in r297270.

Sponsored by: EMC / Isilon Storage Division


# ce6c8db5 31-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

LIB32+WITHOUT_TOOLCHAIN: Fix build by staging includes.

This is the same fix as r297281 for the normal build.

Sponsored by: EMC / Isilon Storage Division


# 497e8091 30-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Remove the old depend (mkdep) code and make FAST_DEPEND the one true way.

Reviewed by: emaste, hselasky (partial), brooks (brief)
Discussed on: arch@
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D5742


# 17e3ebb1 25-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Fix libcompat not handling some external toolchain flags.

- Use libc++ with GCC.
- Use CROSS_BINUTILS_PREFIX with -B (r280980 addressed this mostly already)

Sponsored by: EMC / Isilon Storage Division


# 1b337a34 25-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Build libcompat (lib32) with a --sysroot pointing into its stage directory.

This overrides the cross-compiler's default sysroot to use the WORLD32's
sysroot for building the lib32 libraries. Previously the cross-compiler
would default the sysroot to the 64bit WORLDTMP and -B/-L/-isystem flags
were used to build using the lib32 files. This leads to multiple issues
discussed later. Some extra headers are now needed to be staged since the
64bit WORLDTMP is not referenced at all for headers. The 64bit WORLDTMP
is still used via PATH for build tools. Overriding the default
target/arch is retained in the CC/CXX overrides.

This allows reverting the LDSCRIPT rewriting in installworld from r296921 and
r235122, thus allowing read-only objdirs to work for installing again.

This removes the need for _LDSCRIPTROOT.

This allows progressing the change to always use --sysroot for the build
rather than only relying on the cross-compiler's default sysroot. The
work for that is in D3970 and needed to resolve WITHOUT_CROSS_COMPILER
not using a --sysroot [1].

PR: 196193 [1]
Sponsored by: EMC / Isilon Storage Division


# 429882e6 25-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

LIBRARIES_ONLY should only be defined during install32.

r245561 added it to prevent extra files from being installed during
the install32 phase (to prevent duplicates in the meta log with -DNO_ROOT).
The flag should not be passed during build32 though since it may
prevent staging of includes during the 'make includes' phase on
library directories.

Sponsored by: EMC / Isilon Storage Division


# 37a8c977 24-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Explicit 'make obj' for library dirs in build32 is not needed.

In r138291 some directories were explicitly made to run 'make obj',
but each target in 'make libraries' already runs 'make obj' for
each library since r161580.

Sponsored by: EMC / Isilon Storage Division


# bb52d711 12-Mar-2016 Warner Losh <imp@FreeBSD.org>

Use the newly minted Makefile.libcompat to implement libsoft libraries
for the armv6 ABI switch. This also make WITH_LIBSOFT functional on
the arm platform. As a transition thing, this seems to work even
without switching the ABI (we basically build the same libraries
twice when MK_LIBSOFT=yes until the ABI cut over next
month). MK_LIBSOFT remains default no.


# 048ce093 12-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Follow-up r296709: Fix build32 not properly building all libraries.

Pointyhat to: bdrewery
Reported by: antoine


# dba75e9f 11-Mar-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Move Makefile.lib32 to Makefile.libcompat and generalize it.

This is in preparation for LIBSOFT.

This file only supports *1* LIBCOMPAT value currently and must be capitalized.
In Makefile.libcompat given LIBCOMPAT=FOO there can be values set for
LIBFOOCFLAGS, LIBFOOCPUFLAGS, LIBFOOWMAKEENV, LIBFOOWMAKEFLAGS, LIBFOOCPUFLAGS,
and LIBFOODTRACE. These will have the standard cross-build values appended
onto them.

This could be extended to support multiple libcompat libraries in the future
once there is a need.

Reviewed by: imp
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D5612