Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnumake: do not use MAKE_CXX #314716

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions pkgs/development/tools/build-managers/gnumake/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib
, stdenv
, fetchurl
, updateAutotoolsGnuConfigScriptsHook
, autoreconfHook
, guileSupport ? false, guile
# avoid guile depend on bootstrap to prevent dependency cycles
, inBootstrap ? false
Expand All @@ -22,17 +22,20 @@ stdenv.mkDerivation rec {
sha256 = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
};

# to update apply these patches with `git am *.patch` to https://git.savannah.gnu.org/git/make.git
patches = [
# Replaces /bin/sh with sh, see patch file for reasoning
./0001-No-impure-bin-sh.patch
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
# included Makefiles, don't look in /usr/include and friends.
./0002-remove-impure-dirs.patch
];
# To update patches:
# $ version=4.4.1
# $ git clone https://git.savannah.gnu.org/git/make.git
# $ cd make && git checkout -b nixpkgs $version
# $ git am --directory=../patches
# $ # make changes, resolve conflicts, etc.
# $ git format-patch --output-directory ../patches --diff-algorithm=histogram $version
#
# TODO: stdenv’s setup.sh should be aware of patch directories. It’s very
# convenient to keep them in a separate directory but we can defer listing the
# directory until derivation realization to avoid unnecessary Nix evaluations.
Comment on lines +33 to +35
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #335579

patches = lib.filesystem.listFilesRecursive ./patches;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote on #335579, I sort of love the old approach where the patches are just listed out. I'm willing to hear the case, but my "do the most simple thing" grugbrain triggers when there's magical patch application.

I'm willing to experiment, though.


nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ] ++ lib.optionals guileEnabled [ pkg-config ];
nativeBuildInputs = [ autoreconfHook pkg-config ];
buildInputs = lib.optionals guileEnabled [ guile ];

configureFlags = lib.optional guileEnabled "--with-guile"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From e00a5257a6ca5fedbf68b09eee7df3502971a057 Mon Sep 17 00:00:00 2001
From b69e3740e68afaec97b9957d40b9c135db87eaab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Sat, 24 Apr 2021 10:11:40 +0200
Subject: [PATCH 1/2] No impure bin sh
Subject: [PATCH 1/3] No impure bin sh

default_shell is used to populuate default shell used to execute jobs.
Unless SHELL is set to a different value this would be /bin/sh.
Expand All @@ -18,10 +18,10 @@ hard-coded has some advantages:
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/job.c b/src/job.c
index ae1f18b..6b4ddb3 100644
index ea885614..8a9bd8e0 100644
--- a/src/job.c
+++ b/src/job.c
@@ -77,7 +77,7 @@ char * vms_strsignal (int status);
@@ -76,7 +76,7 @@ char * vms_strsignal (int status);

#else

Expand All @@ -31,5 +31,5 @@ index ae1f18b..6b4ddb3 100644

#endif
--
2.31.1
2.44.1

Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
From 795d63d3c8b5c0dbb7e544954f75507b371b7228 Mon Sep 17 00:00:00 2001
From 2db52008be2e2d504889f4f19318c2ba5a2a4797 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Sat, 24 Apr 2021 10:20:16 +0200
Subject: [PATCH 2/2] remove impure dirs
Subject: [PATCH 2/3] Remove impure dirs

Purity: don't look for library dependencies (of the form `-lfoo') in
/lib and /usr/lib. It's a stupid feature anyway. Likewise, when
searching for included Makefiles, don't look in /usr/include and
friends.
Comment on lines +6 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken from the comment in the Nix file (and I appreciate it here!)

---
src/read.c | 3 ---
src/remake.c | 2 --
2 files changed, 5 deletions(-)

diff --git a/src/read.c b/src/read.c
index fa197fb..defacfb 100644
index b0fc1e1f..d6b41c17 100644
--- a/src/read.c
+++ b/src/read.c
@@ -109,9 +109,6 @@ static const char *default_include_directories[] =
#endif
@@ -111,9 +111,6 @@ static const char *default_include_directories[] =
INCLUDEDIR,
#endif
#ifndef _AMIGA
- "/usr/gnu/include",
- "/usr/local/include",
Expand All @@ -23,10 +27,10 @@ index fa197fb..defacfb 100644
0
};
diff --git a/src/remake.c b/src/remake.c
index fb237c5..94bff7d 100644
index fe67ab28..1b76560c 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -1601,8 +1601,6 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
@@ -1690,8 +1690,6 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
static const char *dirs[] =
{
#ifndef _AMIGA
Expand All @@ -36,5 +40,5 @@ index fb237c5..94bff7d 100644
#if defined(WINDOWS32) && !defined(LIBDIR)
/*
--
2.31.1
2.44.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
From 3317b3a78666e6073c63f62a322176e3dc680461 Mon Sep 17 00:00:00 2001
From: Ivan Trubach <mr.trubach@icloud.com>
Date: Sat, 17 Aug 2024 22:35:03 +0300
Subject: [PATCH 3/3] Do not search for a C++ compiler and set MAKE_CXX
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Removes unnecessary reference to C++ compiler if CXX is set to an
absolute path. If CXX is not an absolute path, we avoid defaulting CXX
to a compiler name that was used to build the package.

Context: GNU Make defines default values for CC, CXX and other
environment variables. For CXX, it usually defaults to g++, however,
FreeBSD and OpenBSD no longer ship GCC as a system compiler (and use
Clang instead). For C compiler, POSIX standardizes the name to be "cc",
but there is no such standard for C++ compiler name. As a fix, GNU Make
uses CXX set for build as a default (via MAKE_CXX preprocessor macro in
the source code).

We revert the change that added this behavior and set the default to c++
or g++ that does not depend on the build platform.

In stdenv, CXX environment variable is always defined and overrides the
default value.

References:
• https://savannah.gnu.org/bugs/?63668
• https://git.savannah.gnu.org/cgit/make.git/commit/?id=ffa28f3914ff402b3915f75e4fed86ac6fb1449d
---
configure.ac | 2 --
src/default.c | 19 ++++++-------------
2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index cd785754..41a65307 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,8 +37,6 @@ AM_INIT_AUTOMAKE([1.16.1 foreign -Werror -Wall])
# Checks for programs.
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
-AC_PROG_CXX
-AC_DEFINE_UNQUOTED(MAKE_CXX, ["$CXX"], [Default C++ compiler.])

# Configure gnulib
gl_EARLY
diff --git a/src/default.c b/src/default.c
index e396269b..78ba402f 100644
--- a/src/default.c
+++ b/src/default.c
@@ -528,22 +528,15 @@ static const char *default_variables[] =
#ifdef GCC_IS_NATIVE
"CC", "gcc",
"OBJC", "gcc",
+# ifdef __MSDOS__
+ "CXX", "gpp", /* g++ is an invalid name on MSDOS */
+# else
+ "CXX", "g++",
+# endif /* __MSDOS__ */
#else
"CC", "cc",
"OBJC", "cc",
-#endif
-#ifdef MAKE_CXX
- "CXX", MAKE_CXX,
-#else
-# ifdef GCC_IS_NATIVE
-# ifdef __MSDOS__
- "CXX", "gpp", /* g++ is an invalid name on MSDOS */
-# else
- "CXX", "gcc",
-# endif /* __MSDOS__ */
-# else
- "CXX", "g++",
-# endif
+ "CXX", "c++",
#endif
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
and to the empty string if $@ does exist. */
--
2.44.1