Commit graph

403 commits

Author SHA1 Message Date
bsiegert
64896df507 bsd.prefs.mk: set OS_VARIANT=Microsoft if used under WSL.
WSL is Windows Services for Linux, aka "bash on Ubuntu on Windows".
Some packages need to differentiate plain Linux and running on WSL.

Patch from David Weller-Fahy via PR pkg/53806.
2019-01-06 12:51:45 +00:00
jperkin
71e098497c mk: Add CTF infrastructure support.
Platform support is determined by _OPSYS_SUPPORTS_CTF from mk/platform, the
user enables support by setting PKGSRC_USE_CTF=yes, and packages can
explicitly disable support with CTF_SUPPORTED=no or skip certain files with
CTF_FILES_SKIP.

The path to ctfconvert is configured via TOOLS_PLATFORM.ctfconvert.

If all of the requisite variables are enabled, a compiler-specific debug flag
is passed via the wrappers to ensure we have DWARF information to convert,
_INSTALL_UNSTRIPPED is explicitly defined to avoid binaries being stripped
prior to conversion, and the conversion is performed during the install stage.

It is recommended that users who enable the feature also set STRIP_DEBUG=yes
to reduce the final binary size once the conversion has been performed.

This has been used for the past year in Joyent SmartOS builds.  FreeBSD is
marked as supported but is untested.
2018-11-12 14:22:58 +00:00
sevan
9ba78728c0 Minix 3 is ELF based 2018-10-29 01:50:00 +00:00
sevan
0a5a21105a libcompat_minix was removed some years back and minlib does not exist as a
linkable library in 3.4RC6 so don't try to link against these.
2018-10-28 18:41:41 +00:00
sevan
f5cbdf9aa2 Minix runs on platforms besides x86, match GNU config.guess. 2018-10-28 18:08:15 +00:00
maya
049476ecd8 mips64 is more likely not 64bit. 2018-07-16 19:53:53 +00:00
maya
78432ca7c3 Describe some of the security mitigation flags and their impact 2018-05-23 11:26:54 +00:00
jperkin
dc208e1a90 mk: Introduce *_SUPPORTED variables for security features.
Using variables such as PKGSRC_USE_SSP in package Makefiles to disable SSP does
not work due to the parsing order in bsd.prefs.mk.  Even if it did, it's not a
good idea to mix user and package settable variables, and would cause issues in
complex packages where bsd.prefs.mk is included early (e.g. Makefile.common).

Packages can now set {MKPIE,MKREPRO,FORTIFY,RELRO,SSP,STACK_CHECK}_SUPPORTED=no
to correctly disable security features if necessary.
2018-01-15 09:35:45 +00:00
khorben
42bd86cfb0 Add initial support for building packages reproducibly
It currently tackles two problems:
- gcc(1) hard-coding full paths in debugging information (with one
  caveat at the moment)
- ar(1) hard-coding user IDs in archive headers

This allows packages built from the same tree and options to produce
identical results bit by bit. This option should be combined with ASLR
and PKGSRC_MKPIE to avoid predictable address offsets for attackers
attempting to exploit security vulnerabilities.

This is still disabled by default, and only supports NetBSD so far.

As discussed on tech-pkg@
2017-11-12 13:34:14 +00:00
bsiegert
60ec14b08f Support OS_VARIANT on Linux, support ChromeOS.
This adds a detection for Chrome OS and Chromium OS based on /etc/lsb-release,
which sets LOWER_VENDOR, like for other Linux distros. It also sets OS_VARIANT
to the value of LOWER_VENDOR, so we can have conditionals for ChromeOS. It is
missing some things that are silently assumed to be part of Linux base
systems, such as POSIX attr support, NIS and more.

ok jperkin@
2017-11-03 18:07:40 +00:00
khorben
e519f07826 Register support for PKGSRC_USE_STACK_CHECK
This adds -fstack-check to the CFLAGS (with GCC on NetBSD x86). Only
tested on NetBSD/amd64 so far.

Disabled by default.
2017-07-09 14:30:07 +00:00
jlam
0a676f1f26 Provide switch to activate new frameworks to replace "pkginstall".
If ${_USE_NEW_PKGINSTALL} is "yes", then use the new "pkgtasks",
"init", and "pkgformat/pkg"-scripts frameworks instead of the
existing "pkginstall" framework.
2017-06-01 02:15:10 +00:00
jlam
b110ad9dac Move detection of shared library type into the platform file.
Only four platforms, all BSDs, need to resolve "ELF/a.out" into
either ELF or a.out.  Calculate it directly in the platform file
and return the value in ${_OPSYS_SHLIB_TYPE} and export that value
in bsd.prefs.mk as ${SHLIB_TYPE}.

Instead of requiring the file(1) tool, we can expect the base
system of those BSDs to have /usr/bin/file, so make use of it
directly.
2017-05-31 22:55:01 +00:00
khorben
4211ac7e85 Add granularity to PKGSRC_USE_FORTIFY and PKGSRC_USE_RELRO
The new options are, for FORTIFY:
  "no"     Do not pass any flags for FORTIFY
  "weak"   Pass -D_FORTIFY_SOURCE=1
  "strong" Pass -D_FORTIFY_SOURCE=2

This allows users to reduce the level of FORTIFY specified if necessary
or desired. The previous setting as "yes" is now equivalent to "strong"
(the default when enabling).

The new options are, for RELRO:
  "no"      Do not pass any flags for RELRO
  "partial" Pass -Wl,-z,relro
  "full"    Pass -Wl,-z,relro -Wl,-z,now

This allows users to reduce the level of RELRO specified if necessary or
desired. The previous setting as "yes" is now equivalent to "full" (the
default when enabling).

This is intended to match the changes committed by jperkin@ (for SSP)
after our discussion a (long) while back.

No functional change intended (with the settings supported so far).
2017-04-16 23:12:37 +00:00
sevan
3425d1a52b powerpc64le is little endian. 2017-02-01 09:55:07 +00:00
jperkin
b673fabd21 Add support for enabling cwrappers automatically. USE_CWRAPPERS now defaults
to "auto", which will enable cwrappers if the _OPSYS_SUPPORTS_CWRAPPERS
platform variable is set to "yes".

Switch over to cwrappers by default for Darwin, Linux, and SunOS (except when
using the sunpro compiler).
2016-10-27 10:31:05 +00:00
jperkin
c02e752f64 Change PKGSRC_USE_SSP to a quad option. The options are now:
"no"     Do not pass any stack protection flags (the default)
   "yes"    Pass -fstack-protector
   "strong" Pass -fstack-protector-strong
   "all"    Pass -fstack-protector-all

This allows users to configure the level of stack smashing protection they
require, and ensures consistent behaviour across platforms.  Users running
on NetBSD who previously used the option will need to change "yes" to "all"
to match the previous default configuration for that platform.

While here use _WRAP_EXTRA_ARGS to ensure the flag gets passed regardless
of whether the package honours CFLAGS, and support additional wrappers.

Discussed a while back with khorben, and used in production for the SmartOS
2016Q1 package sets with the "strong" option.
2016-06-13 13:26:42 +00:00
jperkin
901f82f6b8 Revert part of the MACHINE_ARCH cleanup that resulted in the Linux/x86_64
triplet reporting as x86_64-pc-linux.  Go back to the previous triplet of
x86_64-unknown-linux which matches what config.guess outputs.
2016-04-17 08:13:09 +00:00
joerg
639d5b402f Remove support for USE_DESTDIR=no. 2016-04-10 15:58:02 +00:00
joerg
54362eeca1 Remove last glue for PKG_DESTDIR_SUPPORT=none. 2016-04-10 15:10:12 +00:00
joerg
bfef30f0c8 Drop support for PKG_DESTDIR_SUPPORT=none. 2016-04-10 15:08:39 +00:00
jperkin
3c2941b993 Since the MACHINE_ARCH cleanup, the bootstrap for i386-on-x86_64 Linux has
been broken due to NATIVE_MACHINE_ARCH no longer being set to x86_64.  Fix
this by introducing HOST_MACHINE_ARCH which refers to the underlying host
architecture rather than bmake's native architecture, thus differentiating
between cross-compiling and multilib.

This is currently only set on Linux as the only OPSYS which currently
requires such a test, but can be expanded to other OPSYS as necessary.
2016-03-17 16:02:23 +00:00
khorben
03a56367ef Re-arrange support for FORTIFY/MKPIE/RELRO/SSP
- No _GCC_* anything in mk/bsd.prefs.mk;
- No compiler flags in platform files.

Tested again on NetBSD/amd64, with and without cwrappers, with the same
outcome.

With feedback from jperkin@
2016-03-11 23:54:08 +00:00
khorben
dc4ad6b750 Add support for a number of security features
- Revisit (and rename) support for FORTIFY as PKGSRC_USE_FORTIFY (instead
  of PKGSRC_USE_FORT) for easier support outside NetBSD/gcc;
- PKGSRC_USE_SSP is no longer enabled by default when PKGSRC_USE_FORTIFY
  is enabled;
- PKGSRC_MKPIE builds executables as PIE (to leverage userland ASLR)
- PKGSRC_USE_RELRO builds with a read-only GOT to prevent some exploits
  from functioning.

Tested on NetBSD/amd64 by myself, in every combination, with and without
pkgtools/cwrappers. MKPIE is not supported at the moment with cwrappers.
Also, MKPIE is known to still break a number of packages when enabled (and
actually supported).

Tested on SunOS by jperkin@, thank you!

As discussed on tech-pkg@, the default behavior is not changed, except
where noted above.

ok bsiegert@
2016-03-11 23:03:31 +00:00
tnn
7ca6d09a6a let's do just "Solaris" instead of "Oracle"
The only current use of this is pbulk's subject line, and Solaris 11.3
makes more sense than Oracle 11.3.
2016-03-11 05:42:35 +00:00
tnn
52872bb412 for SunOS, assume that OS_VARIANT is Oracle if no match on other variants
for OmniOS, stop processing /etc/release after the first line
2016-03-11 04:58:51 +00:00
jperkin
111893bb36 Remove _OPSYS_WHOLE_ARCHIVE_FLAG and _OPSYS_NO_WHOLE_ARCHIVE_FLAG, these
variables are unused and in at least one case were completely wrong anyway.
2016-03-10 16:58:19 +00:00
jperkin
ac56158090 Attempt to bring sanity to how ABI and MACHINE_ARCH are set.
Previously there were at least 5 different ways MACHINE_ARCH could be set,
some statically and some at run time, and in many cases these settings
differed, leading to issues at pkg_add time where there was conflict
between the setting encoded into the package and that used by pkg_install.

Instead, move to a single source of truth where the correct value based on
the host and the chosen (or default) ABI is determined in the bootstrap
script.  The value can still be overridden in mk.conf if necessary, e.g.
for cross-compiling.

ABI is now set by default and if unset a default is calculated based on
MACHINE_ARCH.  This fixes some OS, e.g. Linux, where the wrong default was
previously chosen.

As a result of the refactoring there is no need for LOWER_ARCH, with
references to it replaced by MACHINE_ARCH.  SPARC_TARGET_ARCH is also
removed.
2016-01-24 16:14:44 +00:00
rillig
d904a0c3e5 Added keyword "platform" for "bmake help" 2016-01-12 19:55:41 +00:00
joerg
d0abbc4cdc Make USE_DESTDIR != yes an error. 2015-12-27 12:37:29 +00:00
sevan
93d320158c With OpenBSD/amd64 & Bitrig/amd64 switched to using MACHINE_ARCH=x86_64,
amd64 no longer needs to be accounted for specifically.
Remove redundant references.


Reviewed by wiz@
2015-11-07 20:00:19 +00:00
sevan
4de02a05c5 Add the necessary logic for setting Bitrig/amd64 to Bitrig/x86_64.
Switch to using arch(1) to populate $LOWER_ARCH on Bitrig

Reviewed by wiz@
2015-11-07 19:53:49 +00:00
sevan
266cff67cd Add the necessary logic for setting OpenBSD/amd64 to OpenBSD/x86_64.
Reviewed by wiz@
2015-11-07 13:35:44 +00:00
sevan
5481fd2fed Add the mapping for amd64 to its GNU architecture name x86_64.
Needed for switching OpenBSD/amd64 & Bitrig/amd64 to x86_64.

Reviewed by wiz@
2015-10-17 01:50:46 +00:00
jperkin
8a8b2cd412 Ensure OBJECT_FMT is set to ELF on Linux rather than relying on the NetBSD
MAHCINE_ARCH settings in bsd.own.mk.  Fixes at least Sevan's arm64 host.
2015-09-08 12:07:55 +00:00
jperkin
e5e50a0024 Remove NetBSD 0.x and 1.x settings, these have long since been unsupported. 2015-09-08 11:36:34 +00:00
sevan
2e45b2e256 Introduce $LOWER_VARIANT_VERSION, this is used to store version info for variant
Operating Systems.
For SmartOS, store the result from running uname -v & trimming the joyent_
prefix.
For OmniOS, store the result from processing /etc/release with awk(1)


Reviewed by joerg@ bsiegert@
2015-07-25 15:11:09 +00:00
joerg
11d2712a27 Remove USE_X11BASE and X11PREFIX. 2015-07-04 16:18:28 +00:00
sevan
8514571a7a Introduce preliminary support for Bitrig to pkgsrc
Initial patchset to add support by rodent@
Further adjustments made based on feedback by joerg@
Tested by myself with numerous bulkbuilds thanks to Patrick Wildt @ Bitrig

Reviewed by bsiegert@ joerg@ wiz@
2015-06-04 15:48:45 +00:00
jperkin
1a2757e82f Introduce _USE_CWRAPPERS logic to ensure consistency, USE_CWRAPPERS could
differ between a package and user setting, resulting in incorrect WRAPPER_*
values being set from wrapper-defs.mk.
2015-04-29 14:23:23 +00:00
tnn
a0c69e7229 correct MACHINE_ARCH and compiler flags for HP-UX 64-bit ABI 2015-04-27 10:33:49 +00:00
joerg
7049152f2f Specify safer WRKSRC for meta packages. As they don't extract files,
they won't create the subdirectory either. Since the SUBST targets try
to change to WRKSRC first, they fail. This is seen with meta packages
depending on Freetype2 when using X11_TYPE=native.
2015-04-19 01:37:55 +00:00
sevan
5e14f67fd5 OS X Tiger & prior used X11 from XFree86 project which is installed in
/usr/X11R6, set X11BASE to this location on those versions.

Reviewed by wiz@
2015-03-14 17:37:19 +00:00
riastradh
d50065e40e Fix typo: NATIVE_MACHINE_ARCH, not NATIVE-MACHINE_ARCH. Thanks, prlw1! 2015-02-24 13:26:34 +00:00
jperkin
9bd9dd1345 Put back SCO LOWER_OPSYS changes. 2015-02-16 10:43:36 +00:00
riastradh
82fa031ffe Accommodate an -eabi{,hf} suffix in MACHINE_GNU_PLATFORM.
This is necessary to match what NetBSD `build.sh tools' generates for
cross-compiler toolchains on earm.

Also, split APPEND_ELF into APPEND_ELF and NATIVE_APPEND_ELF, so we
don't get a spurious netbsdelf in NATIVE_MACHINE_GNU_PLATFORM when
cross-compiling on amd64 for earm.
2015-02-14 05:01:32 +00:00
obache
5626a25ce6 Revert "Move version part from LOWWER_OPSYS to LOWER_OPSYS_VERSUFFIX for sco.",
proposed/discussed is required for such changes.
2015-02-01 11:33:08 +00:00
dholland
3574122bf5 Add a bunch of missing LP64PLATFORMS after reviewing the list in NetBSD's
build.sh:
	*-*-aarch64{,eb}
	*-*-ia64
	*-*-mips64{eb,el}
	*-*-powerpc64
	*-*-riscv64
2015-01-01 09:00:28 +00:00
dholland
9ccf5c3c80 Add BIGENDIANPLATFORMS and LITTLEENDIANPLATFORMS, like LP64PLATFORMS, for
restricting broken packages.
2015-01-01 08:57:23 +00:00
dholland
de73f20ecb Add support for BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM, as per
discussion on tech-pkg.

BROKEN_ON_PLATFORM and NOT_FOR_PLATFORM are the same, except that
(now) BROKEN_ON_PLATFORM sets PKG_FAIL_REASON and NOT_FOR_PLATFORM
sets PKG_SKIP_REASON. BROKEN_EXCEPT_FOR_PLATFORM and ONLY_FOR_PLATFORM
correspond in the same way.

The idea is that going forward we will distinguish unbuildable
packages that theoretically ought to be fixed (these are BROKEN) from
packages where it doesn't make sense to build (these are NOT_FOR)...
examples of the former include most non-64-bit-clean packges; examples
of the latter include OS-specific language bindings.

A general review of the uses of NOT_FOR_PLATFORM and ONLY_FOR_PLATFORM
(converting many of them to BROKEN...) is coming up.

Similarly, a general review of the uses of PKG_FAIL_REASON and
PKG_SKIP_REASON is coming up.

For this to become useful, pbulk needs to be taught to report failing
and skipped packages differently - the idea is that failing packages
should be reported up front and skipped packages don't need to be. This
has not been done yet, but one set of things at a time...
2015-01-01 06:06:06 +00:00