ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.12k stars 5.73k forks source link

Build error due to `-z` option being passed to `ld.gold` #15132

Closed Spixmaster closed 4 months ago

Spixmaster commented 4 months ago

v0.8.26 does not build.

    cmake -B ./build/ \
        -D CMAKE_BUILD_TYPE=None \
        -D CMAKE_INSTALL_PREFIX=/usr/ \
        -D ONLY_BUILD_SOLIDITY_LIBRARIES=OFF \
        -D PEDANTIC=ON \
        -D PROFILE_OPTIMIZER_STEPS=OFF \
        -D SOLC_LINK_STATIC=OFF \
        -D SOLC_STATIC_STDLIBS=OFF \
        -D STRICT_NLOHMANN_JSON_VERSION=OFF \
        -D STRICT_Z3_VERSION=OFF \
        -D TESTS=OFF \
        -D USE_SYSTEM_LIBRARIES=OFF \
        -D USE_Z3=OFF \
        -S ./ \
        -Wno-dev
    cmake --build ./build/

results in

[ 94%] Built target libsolc
[ 94%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/FitnessMetrics.cpp.o
[ 94%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/Chromosome.cpp.o
[ 95%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/Mutations.cpp.o
[ 95%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/PairSelections.cpp.o
[ 95%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/Selections.cpp.o
[ 96%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/ProgramCache.cpp.o
[ 96%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/Program.cpp.o
[ 96%] Building CXX object tools/CMakeFiles/phaser.dir/yulPhaser/SimulationRNG.cpp.o
[ 97%] Linking CXX static library libsolcli.a
[ 97%] Built target solcli
[ 97%] Building CXX object solc/CMakeFiles/solc.dir/main.cpp.o
[ 98%] Linking CXX static library libphaser.a
[ 98%] Built target phaser
[ 98%] Building CXX object tools/CMakeFiles/yul-phaser.dir/yulPhaser/main.cpp.o
[ 99%] Linking CXX executable yul-phaser
/usr/bin/ld.gold: pack-relative-relocs: unknown -z option
/usr/bin/ld.gold: use the --help option for usage information
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[2]: *** [tools/CMakeFiles/yul-phaser.dir/build.make:108: tools/yul-phaser] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:641: tools/CMakeFiles/yul-phaser.dir/all] Fehler 2
make[1]: *** Es wird auf noch nicht beendete Prozesse gewartet …
[100%] Linking CXX executable solc
/usr/bin/ld.gold: pack-relative-relocs: unknown -z option
/usr/bin/ld.gold: use the --help option for usage information
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[2]: *** [solc/CMakeFiles/solc.dir/build.make:108: solc/solc] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:708: solc/CMakeFiles/solc.dir/all] Fehler 2
make: *** [Makefile:136: all] Fehler 2
==> FEHLER: Ein Fehler geschah in build().
    Breche ab...
Fehler: ‚solidity-0.8.26-1‘ konnte nicht erstellt werden:
Fehler: Pakete konnten nicht erstellt werden: solidity-0.8.26-1
Spixmaster commented 4 months ago

The error is caused by makepkg from Arch Linux applying -z. Maybe ld should be used instead of ld.gold in this project.

cameel commented 4 months ago

This can be overridden using the USE_LD_GOLD CMake variable.

But overall, we do seem to explicitly select ld.gold for linking, though TBH I don't have a strong preference on the matter and never investigated why this was done. This code has been there since very early in the project history. Any specific reasons to revert to ld?

Spixmaster commented 4 months ago

@cameel I have never bothered about the difference. I think that ld supports more options and is the standard. It is up to you. Since it is configurable, this is no big issue. Maybe it would be a good approach to just switch the default value to OFF.

Spixmaster commented 4 months ago

@cameel Maybe an interesting side note. The resulting installation shrunk from 14.92 MiB to 14.33 MiB when switching from ld.gold to ld. Installation via https://aur.archlinux.org/packages/solidity. Considering the installation contains much documentation which was not affected by a change of the linker, the binaries must be the reason for all the size difference.

Gesamtgröße der installierten Pakete:  14,33 MiB
Größendifferenz der Aktualisierung:    -0,59 MiB
cameel commented 3 months ago

Thanks for the info. We'll consider it (I created an issue: #15199), though TBH it's pretty low on our list of priorities. The decreased size does seem nice, but the difference is not that large and I'm not sure about potential downsides. Investigating that may eat time that is probably better spent on other, much more pressing things, like fixing the horrible compilation times via IR.