Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 729888 - dev-libs/libsecp256k1 fails to compile without GCC installed
Summary: dev-libs/libsecp256k1 fails to compile without GCC installed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Matt Whitlock
URL:
Whiteboard:
Keywords: PullRequest
Depends on: 942990
Blocks: systemwide-clang
  Show dependency tree
 
Reported: 2020-06-27 14:15 UTC by Agostino Sarubbo
Modified: 2024-12-01 11:51 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,14.37 KB, text/plain)
2020-06-27 14:15 UTC, Agostino Sarubbo
Details
other.tar.bz2 (other.tar.bz2,6.25 KB, application/x-bzip-compressed-tar)
2020-06-27 14:15 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2020-06-27 14:15:31 UTC
@@This is an auto-filed bug@@
Feel free to change the summary at your convenience.

Issue: dev-libs/libsecp256k1 fails to compile.
Discovered on: amd64

NOTE:
This machine uses a clang/LLVM toolchain.
If you think that this issue is strictly related to clang/LLVM please mention it in the summary and block bug 408963. If you need further logs, feel free to ask.
Comment 1 Agostino Sarubbo gentoo-dev 2020-06-27 14:15:38 UTC
Created attachment 646790 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2020-06-27 14:15:42 UTC
Created attachment 646792 [details]
other.tar.bz2

other logs
Comment 3 Luke-Jr 2020-06-27 19:26:41 UTC
This is using AX_PROG_CC_FOR_BUILD to determine the correct compiler to target the build system (in case of cross compiling). This is needed because it runs custom code at build time to pre-generate data for the final library.

How are other packages that use AX_PROG_CC_FOR_BUILD being fixed? I don't see any commits upstream relating to clang...?
Comment 4 Agostino Sarubbo gentoo-dev 2020-06-30 09:03:04 UTC
FTR gcc is installed here, I'm just using clang by setting the relative env variables.
Comment 5 Luke-Jr 2020-06-30 11:22:00 UTC
(In reply to Agostino Sarubbo from comment #4)
> FTR gcc is installed here, I'm just using clang by setting the relative env
> variables.

Must not be in PATH or something?
Comment 6 Agostino Sarubbo gentoo-dev 2020-06-30 12:10:58 UTC
(In reply to Luke-Jr from comment #5)
> (In reply to Agostino Sarubbo from comment #4)
> > FTR gcc is installed here, I'm just using clang by setting the relative env
> > variables.
> 
> Must not be in PATH or something?

yes, I have gcc-config with USE="-native-symlinks"
Comment 7 Matt Whitlock 2024-11-06 15:26:07 UTC
If you want to use Clang as your system-wide compiler, then you probably should be setting the *_FOR_BUILD env vars as well. Those ought to be set in profiles/features/llvm/make.defaults, but I see they presently are not.

When I set

CPP=x86_64-pc-linux-gnu-clang-cpp-19
CC=x86_64-pc-linux-gnu-clang-19
CXX=x86_64-pc-linux-gnu-clang-19
CPP_FOR_BUILD="${CPP}"
CC_FOR_BUILD="${CC}"
CXX_FOR_BUILD="${CXX}"

then dev-libs/libsecp256k1-0.3.0 compiles using Clang and doesn't touch GCC at all.

I think the root of the issue is that AX_PROG_CC_FOR_BUILD and AX_PROG_CXX_FOR_BUILD work by monkey-patching all the variable names to have "_FOR_BUILD" suffixes and then running the standard AC_PROG_CC or AC_PROG_CXX. The gotcha with this is that the standard macros will then be looking to pull default values from environment variables suffixed with "_FOR_BUILD", and the unsuffixed variables won't be examined at all. Arguably, the *_FOR_BUILD macros should be prepopulating any unset _FOR_BUILD variables using the values of the unsuffixed variables when the build is not cross-compiling, prior to running the usual auto-detection logic that typically defaults to GCC. Until that day, though, you can make it work by setting the _FOR_BUILD variables yourself to specify explicitly which compiler you want to use to generate objects to run on the build system.
Comment 8 Matt Whitlock 2024-11-06 15:56:37 UTC
Correction:

CXX=x86_64-pc-linux-gnu-clang++-19
Comment 9 Larry the Git Cow gentoo-dev 2024-12-01 11:51:42 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cacc52acc43245c2aa286f482e9d79f87ca632e3

commit cacc52acc43245c2aa286f482e9d79f87ca632e3
Author:     Matt Whitlock <gentoo@mattwhitlock.name>
AuthorDate: 2024-11-12 17:43:46 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-01 11:49:24 +0000

    dev-libs/libsecp256k1: set build-machine toolchain environment
    
    The dev-libs/libsecp256k1 build uses AX_PROG_CC_FOR_BUILD from
    dev-build/autoconf-archive to detect the toolchain to use for compiling
    tools to run on the build machine during the build. Portage does not
    export the expected *_FOR_BUILD environment variables by default, so we
    have to call tc-export_build_env to set them.
    
    Closes: https://bugs.gentoo.org/729888
    Signed-off-by: Matt Whitlock <gentoo@mattwhitlock.name>
    Closes: https://github.com/gentoo/gentoo/pull/39227
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-libs/libsecp256k1/libsecp256k1-0.5.1.ebuild | 6 +++++-
 dev-libs/libsecp256k1/libsecp256k1-0.6.0.ebuild | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)