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

depends: Use CC_FOR_BUILD for config.guess #29963

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Apr 25, 2024

On the master branch @ 3c88eac, consider the following commands in the depends subdirectory:

$ make print-build HOST=i686-pc-linux-gnu CC="clang -m32"
build=x86_64-pc-linux-gnu
$ make print-host HOST=i686-pc-linux-gnu CC="clang -m32"
host=i686-pc-linux-gnu

The printed variable values are expected.

However, switching the CC variable context from Makefile to the shell environment breaks expectations:

$ CC="clang -m32" make print-build HOST=i686-pc-linux-gnu
build=i686-pc-linux-gnu
$ CC="clang -m32" make print-host HOST=i686-pc-linux-gnu
host=i686-pc-linux-gnu

This PR fixes this issue.

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 25, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

hebasto added a commit to hebasto/bitcoin that referenced this pull request Apr 25, 2024
A workaround for a bug fixed in bitcoin#29963
@theuni
Copy link
Member

theuni commented Apr 25, 2024

Where/why is this an issue?

hebasto added a commit to hebasto/bitcoin that referenced this pull request Apr 25, 2024
A workaround for a bug fixed in bitcoin#29963
@hebasto
Copy link
Member Author

hebasto commented Apr 25, 2024

Where/why is this an issue?

I faced this issue during my work on the CMake staging branch when the CC environment variable was defined by the CI -- https://github.com/hebasto/bitcoin/actions/runs/8822538616/job/24220973382.

The log shows no cross-compiling, but it is cross-compiling to i686-pc-linux-gnu.

@theuni
Copy link
Member

theuni commented Apr 25, 2024

Surely this isn't the only place env vars like this would cause issues? Feels like a cat-and-mouse game.

@maflcko
Copy link
Member

maflcko commented Apr 26, 2024

The log shows no cross-compiling, but it is cross-compiling to i686-pc-linux-gnu.

Can you link to the exact lines in the log that show "no cross-compiling".

@hebasto
Copy link
Member Author

hebasto commented Apr 26, 2024

The log shows no cross-compiling, but it is cross-compiling to i686-pc-linux-gnu.

Can you link to the exact lines in the log that show "no cross-compiling".

https://github.com/hebasto/bitcoin/actions/runs/8822538616/job/24220973382#step:14:245:

Cross compiling ....................... FALSE

Please note that that was a PR branch from the CMake migration project. That branch detects cross-compiling basing on host and build values when building with depends.

@fanquake
Copy link
Member

Surely this isn't the only place env vars like this would cause issues? Feels like a cat-and-mouse game.

Yea, as-is this doesn't seem like a great fix, and may just break other things?

A better diff might be something like:

diff --git a/depends/Makefile b/depends/Makefile
index 005d9696fb..091511758d 100644
--- a/depends/Makefile
+++ b/depends/Makefile
@@ -51,7 +51,7 @@ FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources
 C_STANDARD ?= c11
 CXX_STANDARD ?= c++20
 
-BUILD = $(shell ./config.guess)
+BUILD = $(shell CC_FOR_BUILD=$CC ./config.guess)
 HOST ?= $(BUILD)
 PATCHES_PATH = $(BASEDIR)/patches
 BASEDIR = $(CURDIR)

which would at least be using the option that is meant to be used for this.

Co-authored-by: Michael Ford <fanquake@gmail.com>
@hebasto
Copy link
Member Author

hebasto commented Apr 26, 2024

A better diff might be something like:
...
which would at least be using the option that is meant to be used for this.

I agree. Implemented.

Thanks!

@hebasto hebasto changed the title depends: Do not consider CC environment variable for detecting system depends: Use CC_FOR_BUILD for config.guess Apr 26, 2024
@theuni
Copy link
Member

theuni commented Apr 26, 2024

However, switching the CC variable context from Makefile to the shell environment breaks expectations

Arguably that's because this wasn't intended to be supported :)

I suppose this fix is reasonable, though supporting env vars like this seems quite brittle.

hebasto added a commit to hebasto/bitcoin that referenced this pull request Apr 30, 2024
A workaround for a bug fixed in bitcoin#29963
hebasto added a commit to hebasto/bitcoin that referenced this pull request May 2, 2024
A workaround for a bug fixed in bitcoin#29963
hebasto added a commit to hebasto/bitcoin that referenced this pull request May 2, 2024
A workaround for a bug fixed in bitcoin#29963
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants