Commit graph

358 commits

Author SHA1 Message Date
nia
f4ab3d48e8 mk: default to gfortran on aarch64, there's no g95 for aarch64 2020-03-14 10:00:37 +00:00
maya
400c25c7eb Match indentation. 2020-03-07 15:19:20 +00:00
maya
ea06e5b0d2 Test that the lang/gccN exists before defaulting to N as the gfortran version.
Issue most immediately obvious when trying GCC 9, but probably applies to
some other versions as well.
2020-03-07 15:18:19 +00:00
bacon
fe59885718 mk/compiler/gfortran: Default to same major version as base GCC
GFORTRAN_VERSION should match CC_VERSION as closely as possible for
ABI compatibility.  This update tries to match GFORTRAN_VERSION
to CC_VERSION if the base compiler is GCC.  If base compiler is not
GCC, default to a mainstream version likely to work with base clang/llvm.
2020-02-26 15:58:20 +00:00
rillig
1604275256 mk/compiler/gcc.mk: reorder variables in _VARGROUPS section
By listing the public variables first, the focus is put on the most
important variables.
2019-09-19 06:46:59 +00:00
rillig
95fe8ca6c6 mk/compiler/gcc.mk: add missing variables to _VARGROUPS section 2019-09-18 06:46:13 +00:00
rillig
fe8d2392e3 mk/compiler/gcc.mk: search for GCCBASE/bin/gcc as well
A default installation of GCC doesn't install bin/cc but only bin/gcc.
Adding bin/cc is only done by the pgksrc packages, not by the upstream
package.

The previous strategy of just checking whether ${GCCBASE}/bin/${CC:[1]}
exists did not work in such a situation. Therefore, if CC still has its
default value from sys.mk, that is changed to the intended gcc, which
then detects the base GCC properly.

See https://mail-index.netbsd.org/pkgsrc-users/2019/09/07/msg029329.html.
See https://mail-index.netbsd.org/tech-pkg/2019/09/18/msg021976.html.
2019-09-18 06:35:12 +00:00
rillig
d7f638ee99 mk/compiler: replace complicated :M_asdf_ modifier with :[1]
The :[1] modifier has been added to bmake in 2006.
2019-09-18 06:15:13 +00:00
rillig
e8b4d71240 mk/compiler/gcc.mk: refactoring for PKGPATH comparison
Since PKGPATH can only ever consist of a single path, there is no point
in applying the :M modifier to it.
2019-09-08 09:24:52 +00:00
rillig
a504a7a55a mk/compiler/gcc.mk: improve _VARGROUPS section 2019-09-07 22:20:32 +00:00
rillig
22bac2bbe2 mk/compiler/gcc.mk: update _VARGROUPS 2019-09-07 07:10:15 +00:00
rillig
0ff5dc4a46 mk: use a single form for headings in the documentation comments 2019-09-02 02:23:02 +00:00
ryoon
a73d906dd6 Do not pass -std=c++03 to GCC 4.4
No objection on tech-pkg@.
2019-07-15 16:06:19 +00:00
riastradh
14df6bc748 aarch64 has no compiler flag for ABI=64. 2019-07-09 15:46:02 +00:00
riastradh
2f9efeb223 Avoid passing _CC as cross-compiler to recursive makes.
This way we don't inadvertently tell a native dependency that it is
supposed to be compiled with the cross-compiler.

No functional change intended for USE_CROSS_COMPILE=no.
2019-07-09 15:45:46 +00:00
rillig
21c0a41a76 mk: fix pkglint warnings about ambiguous variables
When a Makefile fragment contains $0, this means a Makefile variable, not
a shell or AWK variable.

The bug in ccc.mk survived unnoticed for almost 15 years. The bug in
gnu-configure.mk for MirBSD got only half as old.
2019-04-20 16:32:42 +00:00
wiz
da5215fd50 Add RELRO support for clang, based on the gcc logic. 2019-01-09 13:19:03 +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
abs
c025aae024 Don't rely on gcc version fallthrough for GCC_REQD+=8
(Thanks to eagle eyes from leot@)
2018-10-29 11:53:18 +00:00
abs
2c974aa3c5 Add GCC_REQD+=8 support to compiler/gcc.mk 2018-10-28 22:22:19 +00:00
abs
752fb11aed Support single digit GCC_REQ values (5, 6 or 7)
Do not add 4 to avoid confusion between gcc44/48/49

Also switch USE_PKGSRC_GCC_RUNTIME checks to use _GCC_PKGBASE to match
against selected gcc
2018-10-09 15:02:48 +00:00
rillig
b353c90862 Remove trailing whitespace 2018-10-08 20:02:17 +00:00
maya
6c25dec844 Remove clauses 3,4 from TNF-only copyright blocks.
This is based on the decision The NetBSD Foundation made in 2008 to
do so, which was already applied to src.

This change has been applied to code which is likely not in other
repositories.

ok board@, reviewed by riastradh@
2018-08-22 20:48:36 +00:00
jperkin
593ba9f18c mk/compiler/gcc.mk: Darwin needs _USE_GCC_SHLIB too. 2018-07-11 11:11:52 +00:00
wiz
b621cbd744 mk/compiler/gcc.mk: move _GCC_LDFLAGS setting for relro.
At the previous location it was overridden if a gcc from pkgsrc was used.

Problem found by bacon@
2018-05-24 05:47:21 +00:00
jperkin
d8bb1d8957 mk: Fix GCC PKGPATH matches. 2018-05-23 10:17:58 +00:00
jperkin
512dfdee29 mk: Add USE_PKGSRC_GCC_RUNTIME gcc7-libs support. 2018-05-23 08:11:59 +00:00
khorben
fd7a4f25a3 Also append the CFLAGS for MKPIE for c++(1)
From spz@, thanks!
2017-11-29 22:55:15 +00:00
khorben
542893c887 Revert "Always add "-fPIC" when linking with PKGSRC_MKPIE"
It seems to break emulators/qemu.
2017-11-15 19:04:24 +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
khorben
24807e5120 Always add "-fPIC" when linking with PKGSRC_MKPIE
This makes sure a simple "cc -o hello hello.c" will still build a valid
executable. It does not let us detect when CFLAGS or LDFLAGS are
ignored anymore, but it is legitimate for packages to expect it to work
without any additional parameter.

ld(1) does not expect "-fPIC" but it seems to be ignored by our wrappers
in this case, so no disruption is expected there.
2017-11-07 16:57:58 +00:00
jperkin
8dbb87e55a mk: Fix SSP detection when using pkgsrc GCC.
We can't rely on _GCC_VERSION as an accurate indicator of the GCC version,
as when using a pkgsrc GCC it will be set to 0 until the pkgsrc GCC is
available and we can detect its version.  Instead, move the logic later to
after CC_VERSION is set and use that instead.
2017-10-03 09:38:16 +00:00
jperkin
3f417abb31 Limit GCC SSP support to 4.x and newer. 2017-09-11 09:06:41 +00:00
khorben
6b7f07a1e4 Add support for PKGSRC_MKPIE with cwrappers
This is based on a patch submitted on 16/04/2017 on tech-pkg@ and
adapted by joerg@ for pkgtools/cwrappers. It only consists in the
missing part to actually generate PIE executables with cwrappers if
configured to do so (currently disabled by default). The aim is really
to produce safer binaries where ASLR is in use.

This part in pkgsrc is only supported on NetBSD (x86) with GCC at the
moment.

Tested on NetBSD/amd64, with and without cwrappers, with and without
PKGSRC_MKPIE (all four combinations).
2017-08-25 01:43:17 +00:00
jperkin
7c713c8b68 Remove obsolete and unused SunOS fortify section. 2017-08-04 08:53:33 +00:00
brook
590147deae Add logic so GCC_REQD+=7.x works. 2017-07-18 18:27:31 +00:00
joerg
03f704711c Retire CLANG_NO_VALUE_PROPAGATION_PASS. CVP has been fixed in LLVM to
require much less memory.
2017-07-11 19:41:20 +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
joerg
5f789069ad Fix typo. 2017-06-25 01:41:15 +00:00
kamil
0e21766de5 Correct ccache(1) typo: CPPATH -> CPPPATH 2017-06-17 02:47:20 +00:00
kamil
df999dfb68 Correct shadowing system compiler with a pkgsrc one in ccache
ccache needs to call real compiler and it detects it with looking in $PATH.
In case of usage of /usr/local/bin/clang as the desired pkgsrc $CC option,
it will be shadowed by /usr/pkg/bin/clang if someone will build it in as a
package. Workaround the problem with setting CCACHE_PATH through
PKGSRC_MAKE_ENV. Little bit overzelaously set it to
${CCPATH:H}:${CXXPATH:H}:${CPPATH:H}, just in case that they might be in
different paths. To ensure that they are not shadowed in narrow cases,
there is an option to rename clang to xclang or similar and use it this
way in $PKG_CC.

While there, introduce new user settable option: CCACHE_LOGFILE.
If set, ccache logs to file specified in ${CCACHE_LOGFILE:Q}.

+# CCACHE_LOGFILE
+#       If set to a file path, ccache will write information on what it is
+#       doing to the specified file. This is useful for tracking down
+#       problems.

This fixes another set of problems building large projects like Clang, LLVM
with ccache.

Sponsored by <The NetBSD Foundation>
2017-06-17 01:44:54 +00:00
jperkin
c657f15637 Consolidate setting of SSP flags now that multiple compilers support it. 2017-05-18 08:14:08 +00:00
khorben
8b017f6b3a Register support for SSP on FreeBSD and clang (on x86 architectures)
Support for SSP (Stack-Smashing Protection) is optional so this should not
affect default builds.

Tested on FreeBSD/amd64 (10.3-RELEASE-p11)
2017-05-18 01:29:55 +00:00
joerg
8b20e378ad Add GCC_VERSION_SUFFIX, which can be used i.e. on SuSE systems to select
between different compiler versions.
2017-05-04 18:44:12 +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
jperkin
4c279ad5d4 Let GCC 4.4 handle requests for GCC 4.[0-4] to ensure we are consistent in
using the closest match for each request, as well as fixing platforms where
GCC 6 does not yet build or is unsupported.
2017-04-10 12:22:07 +00:00
kamil
142e04fc75 Fix path to cross-libtool-base in f2c.mk for crossbuilding 2017-03-05 10:40:18 +00:00
maya
2ab36e5237 Remove last mentions of gcc45,46,47 in mk/.
No functional change intended.
2016-12-29 23:16:26 +00:00
maya
bc1d2b7489 Remove some of the mentions for gcc{45,46,47}.
No functional change intended.
Still a few left.
2016-12-29 23:07:17 +00:00
maya
e2f57f6d5e Make GCC_REQD+= 4.5 to 4.8 resolve to 4.8 (dropping the possibility to
match for 4.5, 4.6, 4.7, which will soon be dropped).

This commit is the functional change. Cleanup will be done in separate
commits.
2016-12-29 22:21:13 +00:00