Skip to content

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 & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29963.

Reviews

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

Conflicts

No conflicts as of last run.

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.

@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
@fanquake
Copy link
Member

Is this still an issue given recent CMake changes?

@hebasto
Copy link
Member Author

hebasto commented Jun 3, 2024

Is this still an issue given recent CMake changes?

Yes. Tested with the master branch @ 80bdd4b.

And this PR still fixes it.

@fanquake
Copy link
Member

@hebasto can you rebase this?

@hebasto
Copy link
Member Author

hebasto commented Oct 24, 2024

@hebasto can you rebase this?

Rebased.

@DrahtBot
Copy link
Contributor

Guix builds (on x86_64) [untrusted test-only build, possibly unsafe, not for production use]

File commit 74fb193
(master)
commit 8cf6a3a
(master and this pull)
SHA256SUMS.part ad80f9275f7592f5... 60cfbff26d3ac855...
*-aarch64-linux-gnu-debug.tar.gz e3f077c9e2efe42c... 1611c2fc3615b36a...
*-aarch64-linux-gnu.tar.gz 84c5837e967a705e... e0db625be9859af1...
*-arm-linux-gnueabihf-debug.tar.gz 198436220bbb764e... 8115f020abf2acf7...
*-arm-linux-gnueabihf.tar.gz 8ab9ee456035f028... fb518d26a6936a6c...
*-arm64-apple-darwin-unsigned.tar.gz 5f3493c8841e7000... 41229727f60b73c3...
*-arm64-apple-darwin-unsigned.zip 53586205b08dae04... 377fcbf11713b0cb...
*-arm64-apple-darwin.tar.gz 9bc61a1a9c494690... 19cf2e7611080487...
*-powerpc64-linux-gnu-debug.tar.gz d736c35074e1ab00... cba9b8d9e094dee0...
*-powerpc64-linux-gnu.tar.gz dc3411d9d8e023d0... 60d275915f058dbe...
*-riscv64-linux-gnu-debug.tar.gz 14f550c7e6be73cb... f881035b90972ed6...
*-riscv64-linux-gnu.tar.gz a5ce20b057de5651... b063b32fa7b6c2d8...
*-x86_64-apple-darwin-unsigned.tar.gz 0a5aeae59a745fdd... ee329307733e0a36...
*-x86_64-apple-darwin-unsigned.zip c17d6c147152032f... 3098eb653ffa25a8...
*-x86_64-apple-darwin.tar.gz eb310f282a01918f... 21a73422bd7b32f1...
*-x86_64-linux-gnu-debug.tar.gz 788598dd19a44259... c470987123553747...
*-x86_64-linux-gnu.tar.gz 6b13f937a5601c35... 57a8a8062bb61dc7...
*.tar.gz d344eb18d56160d8... e059bb50c284f19f...
guix_build.log baf52e47221c27f4... 57984899bf58d2f5...
guix_build.log.diff df4e8b61eda9235c...

@hebasto
Copy link
Member Author

hebasto commented Oct 29, 2024

My Guix build:

aarch64
a2d14a22db6670a4f33aa4a7f9bd04d45cb861993b51670c4c950bf98f68864f  guix-build-707d65ba0d74/output/aarch64-linux-gnu/SHA256SUMS.part
71d45a6c783b287a3369503b34ef08a42b5c4a2c8c2f636cf4665574e4f2f0ac  guix-build-707d65ba0d74/output/aarch64-linux-gnu/bitcoin-707d65ba0d74-aarch64-linux-gnu-debug.tar.gz
3f5fb049c4347d25c091ec4412dfb3a9a6488a28aad2cca7bd52d822ff6b5f0f  guix-build-707d65ba0d74/output/aarch64-linux-gnu/bitcoin-707d65ba0d74-aarch64-linux-gnu.tar.gz
bb8a6a2aa57ea0d7e26523bd0d9bfd32416c31e3e0f7f1facc237f70c1528b16  guix-build-707d65ba0d74/output/arm-linux-gnueabihf/SHA256SUMS.part
abd7c08544aaf6c1c3538a8cdd551eec9e545eac0f2fdaf036d1cf99e6e62933  guix-build-707d65ba0d74/output/arm-linux-gnueabihf/bitcoin-707d65ba0d74-arm-linux-gnueabihf-debug.tar.gz
c1a542509b91945b679e520ff398bee9c3d66e94a3a1c356209b88290ae1202e  guix-build-707d65ba0d74/output/arm-linux-gnueabihf/bitcoin-707d65ba0d74-arm-linux-gnueabihf.tar.gz
c383ab8414f738ac152cfbc8c273bb224593854d605ecd3317f9d4485c672aa1  guix-build-707d65ba0d74/output/arm64-apple-darwin/SHA256SUMS.part
9321290cd61e8c11aa46fa68130011362cc2d0a4d6d89520294f255c2de90dde  guix-build-707d65ba0d74/output/arm64-apple-darwin/bitcoin-707d65ba0d74-arm64-apple-darwin-unsigned.tar.gz
53e9e64ae7f34c19b56528245554a90005ef25af28ef5971eaecb002c821d87c  guix-build-707d65ba0d74/output/arm64-apple-darwin/bitcoin-707d65ba0d74-arm64-apple-darwin-unsigned.zip
1012af184f40d376e3807ee07f4c12b67a1ccaf43ee469d36b0cb4d2d989a53c  guix-build-707d65ba0d74/output/arm64-apple-darwin/bitcoin-707d65ba0d74-arm64-apple-darwin.tar.gz
e725088b69b7f8e1332e488bf0950f1f39ccbb70c632b73dd6548a55861a8efa  guix-build-707d65ba0d74/output/dist-archive/bitcoin-707d65ba0d74.tar.gz
881cc54f072595aee80e3e6557ff69d273e212ff5b9dec01eab2b26b15f5ae7a  guix-build-707d65ba0d74/output/powerpc64-linux-gnu/SHA256SUMS.part
00937e24253737195ddea04e2305c2e1eebff95152409b23ad39aa645cbd5787  guix-build-707d65ba0d74/output/powerpc64-linux-gnu/bitcoin-707d65ba0d74-powerpc64-linux-gnu-debug.tar.gz
4fae317645f9b1ea003b6c6002e00bd4700bbe4be5b24d40f831c68d5cacc595  guix-build-707d65ba0d74/output/powerpc64-linux-gnu/bitcoin-707d65ba0d74-powerpc64-linux-gnu.tar.gz
1db9cd63de6253f01f8ea816847040bf8784c9f8033acc88d52a0b6e5a77dfd4  guix-build-707d65ba0d74/output/riscv64-linux-gnu/SHA256SUMS.part
529314421f8301cf3fe88369c647858f73dff06a0f3710bcaa4d9cd4ba54d90b  guix-build-707d65ba0d74/output/riscv64-linux-gnu/bitcoin-707d65ba0d74-riscv64-linux-gnu-debug.tar.gz
dbe7d077b7707d04f8b90860064a449b84c0869b8e8ba628e5756e80127153a3  guix-build-707d65ba0d74/output/riscv64-linux-gnu/bitcoin-707d65ba0d74-riscv64-linux-gnu.tar.gz
51f2978456c02a6449028a6734e4affcc55002dac2222d546447279eda6aa4ba  guix-build-707d65ba0d74/output/x86_64-apple-darwin/SHA256SUMS.part
90f77b77a538820591efc724416936a601ead4a3eba02fd10e119fa8c6ad01da  guix-build-707d65ba0d74/output/x86_64-apple-darwin/bitcoin-707d65ba0d74-x86_64-apple-darwin-unsigned.tar.gz
ed0971cf057ccb95712822e39d111bb921e735115a494ae6e0160ec5b84fdb2e  guix-build-707d65ba0d74/output/x86_64-apple-darwin/bitcoin-707d65ba0d74-x86_64-apple-darwin-unsigned.zip
a513a1b3cf4a013539a0948e5da007a1574880ccf2df528741ede6107729b465  guix-build-707d65ba0d74/output/x86_64-apple-darwin/bitcoin-707d65ba0d74-x86_64-apple-darwin.tar.gz
0c2030f3ccfbcbf4c1cb410f854802ad6126e9283a57709e980396b5f7c6241c  guix-build-707d65ba0d74/output/x86_64-linux-gnu/SHA256SUMS.part
7a0343c42277c10f6bd833c63d6ea1bbfb19ee99e2c77dc06b07b702a7336396  guix-build-707d65ba0d74/output/x86_64-linux-gnu/bitcoin-707d65ba0d74-x86_64-linux-gnu-debug.tar.gz
7dfc7bc9c6b301e8d51001d8a23077e318ee15d6582d45a0d173bc0269b83eb2  guix-build-707d65ba0d74/output/x86_64-linux-gnu/bitcoin-707d65ba0d74-x86_64-linux-gnu.tar.gz
81d60661f8d1bede83b1c2e1784455bdf0356fca6c3b072c1b3bd75a9a8c3b30  guix-build-707d65ba0d74/output/x86_64-w64-mingw32/SHA256SUMS.part
4a714fafca490232218f2ceb85ff624995f850b71517908e687c6fca0ec6474a  guix-build-707d65ba0d74/output/x86_64-w64-mingw32/bitcoin-707d65ba0d74-win64-debug.zip
3a47127b553e573d23422917d1c0f13901737089c3c4284c8d8814a196821fa2  guix-build-707d65ba0d74/output/x86_64-w64-mingw32/bitcoin-707d65ba0d74-win64-setup-unsigned.exe
b6b3a834a5356034f31564688b1b2d21da2929fe29b6d5c4ae4489b820e2798e  guix-build-707d65ba0d74/output/x86_64-w64-mingw32/bitcoin-707d65ba0d74-win64-unsigned.tar.gz
ee775c94af00706762fa29c827baf93afbd68a075298b062213bce391cc2f043  guix-build-707d65ba0d74/output/x86_64-w64-mingw32/bitcoin-707d65ba0d74-win64.zip

@hebasto
Copy link
Member Author

hebasto commented Feb 10, 2025

@theuni

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.

There are testing environments, such as OSS-Fuzz, that rely on a project's build system to support environment variables.

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

hebasto commented Feb 12, 2025

Rebased to resolve the conflict with the merged #30584.

@hebasto
Copy link
Member Author

hebasto commented Feb 12, 2025

My Guix build:

aarch64
ab623f96d21b9651618ccd3dd1dd547494ecbe199cf1146dfebde4d02cd141a4  guix-build-38d13e68e276/output/aarch64-linux-gnu/SHA256SUMS.part
1f70c006d53d319ebbfb915a909419d5084489e527c8cf24369f113c96705251  guix-build-38d13e68e276/output/aarch64-linux-gnu/bitcoin-38d13e68e276-aarch64-linux-gnu-debug.tar.gz
ae9eb92cdd2eee116bd48199ee9d8093082f58ce158badd47aaaa3cd044d2d9a  guix-build-38d13e68e276/output/aarch64-linux-gnu/bitcoin-38d13e68e276-aarch64-linux-gnu.tar.gz
31c6976e87e9d1e87759ab3057f2c75eb5ed824e0a986a8317dd7b9bcd0d8fa7  guix-build-38d13e68e276/output/arm-linux-gnueabihf/SHA256SUMS.part
2a3ac0e4368c9d83419539db88a886e4f49ad93e67bf6bcc78d88c4118ab40c7  guix-build-38d13e68e276/output/arm-linux-gnueabihf/bitcoin-38d13e68e276-arm-linux-gnueabihf-debug.tar.gz
2a5e990b3c3c236bcfe720d526dbf2a319d15eba81591d280aad15c746511bb9  guix-build-38d13e68e276/output/arm-linux-gnueabihf/bitcoin-38d13e68e276-arm-linux-gnueabihf.tar.gz
c5d8de4a45ed34f3cce046a540421fc05ab0f98937479afe279f645522e5d961  guix-build-38d13e68e276/output/arm64-apple-darwin/SHA256SUMS.part
f12c6ca851f7f1bc88ed8f31aa87cf10aad84974eceab20e463de91ef3508142  guix-build-38d13e68e276/output/arm64-apple-darwin/bitcoin-38d13e68e276-arm64-apple-darwin-unsigned.tar.gz
0e03be196c8d5a40e0fd8cfa397e19f0d61f14fb8ff2ab50bf90a06289b2362d  guix-build-38d13e68e276/output/arm64-apple-darwin/bitcoin-38d13e68e276-arm64-apple-darwin-unsigned.zip
c3705df317214be53b9360f91ca9a4c1721c6bb4dad75cc348afb19d3f5c3858  guix-build-38d13e68e276/output/arm64-apple-darwin/bitcoin-38d13e68e276-arm64-apple-darwin.tar.gz
db57e79fd0d357b99d8d4e762806933ac93d464f19f66b050c9cbe5f52250ab6  guix-build-38d13e68e276/output/dist-archive/bitcoin-38d13e68e276.tar.gz
c221715291996b44d6f4b23afb9add05987d50936d0f52fda64d5ee8410b3806  guix-build-38d13e68e276/output/powerpc64-linux-gnu/SHA256SUMS.part
3c5f3605d0905db76d79fdb84732e0966847c49e0ce0bf676e21c8ba57a1043f  guix-build-38d13e68e276/output/powerpc64-linux-gnu/bitcoin-38d13e68e276-powerpc64-linux-gnu-debug.tar.gz
b7766749323a62b282f01de85877921e957db7c1b59a051d2a1b10c17e8c54c0  guix-build-38d13e68e276/output/powerpc64-linux-gnu/bitcoin-38d13e68e276-powerpc64-linux-gnu.tar.gz
1d2fd609475244b702a3a945f4cf65bbf1ebd1bcabdcd1f8189581255a4ed699  guix-build-38d13e68e276/output/riscv64-linux-gnu/SHA256SUMS.part
c4f08e1f730f89084a05c56ff1eca2962ac1ca83add1cc65ef46fc4a93fd0ea2  guix-build-38d13e68e276/output/riscv64-linux-gnu/bitcoin-38d13e68e276-riscv64-linux-gnu-debug.tar.gz
12a1f93c3bb5aaff41cd9ecb4bf4fe6e09cb251befa06c2d3832706bc6a87d97  guix-build-38d13e68e276/output/riscv64-linux-gnu/bitcoin-38d13e68e276-riscv64-linux-gnu.tar.gz
bc6ab43d9046cccb70fcef4782395bcc71ca0039ab0c63fdd60fbe9de0d0a573  guix-build-38d13e68e276/output/x86_64-apple-darwin/SHA256SUMS.part
aa844cf3c1cec314bd7035845cedadc1240aa7dc77b6510f85735d464f5f84d5  guix-build-38d13e68e276/output/x86_64-apple-darwin/bitcoin-38d13e68e276-x86_64-apple-darwin-unsigned.tar.gz
43d30e0027c18a7aeb439b13b6761373cb53984500b3e99ebb82cac2d7fb11ca  guix-build-38d13e68e276/output/x86_64-apple-darwin/bitcoin-38d13e68e276-x86_64-apple-darwin-unsigned.zip
a4ee31178b1746245f27ed77a61c928f1df39ff916fb83193828666b364a3849  guix-build-38d13e68e276/output/x86_64-apple-darwin/bitcoin-38d13e68e276-x86_64-apple-darwin.tar.gz
f01cff25baea72e8a2ddfeab7e1d04023cfc99176072e6446aebd59cb501dc18  guix-build-38d13e68e276/output/x86_64-linux-gnu/SHA256SUMS.part
9dfcf2c386ea4821425449ff1244aa26b83c70b6fa36767de26be48ff98d069e  guix-build-38d13e68e276/output/x86_64-linux-gnu/bitcoin-38d13e68e276-x86_64-linux-gnu-debug.tar.gz
755689356c0838578db1b7fe61f2b0727e8cdddccd015a7f69188174149a981a  guix-build-38d13e68e276/output/x86_64-linux-gnu/bitcoin-38d13e68e276-x86_64-linux-gnu.tar.gz
b0f47c75baea43007e7cf8469634121086068cb6658107a46faef2e0b2f7d64c  guix-build-38d13e68e276/output/x86_64-w64-mingw32/SHA256SUMS.part
b6a07fc34dc3c50ae4804aebfbfcfdd05f553e80df73dfa9de78790e5f395250  guix-build-38d13e68e276/output/x86_64-w64-mingw32/bitcoin-38d13e68e276-win64-debug.zip
154d6cb011f475b21c0941a568662ada35654cff20d05fd0cd4dd28214e8c169  guix-build-38d13e68e276/output/x86_64-w64-mingw32/bitcoin-38d13e68e276-win64-setup-unsigned.exe
ca2708afbadea82d840a69885d5b5f6f233b32ff5b512e20b5f34c7e51c18875  guix-build-38d13e68e276/output/x86_64-w64-mingw32/bitcoin-38d13e68e276-win64-unsigned.tar.gz
e7c0ece29c932db0747bfa5e7924b9553c1dd18e21f5c066f58d33ecb1e8b5c3  guix-build-38d13e68e276/output/x86_64-w64-mingw32/bitcoin-38d13e68e276-win64.zip

@theuni
Copy link
Member

theuni commented Feb 12, 2025

I don't understand this change. It seems setting CC_FOR_BUILD to CC is exactly the opposite of what we want to do?

@hebasto's original change makes more sense to me:

BUILD = $(shell env --unset CC ./config.guess)

That ignores what's set in CC when detecting the native platform, which seems like the correct behavior to me.

What was your intention with this patch, @fanquake ?

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.

5 participants