-
Notifications
You must be signed in to change notification settings - Fork 544
Description
I'm not sure if this is a bug in rustc, or a print
line that needs to be updated in cc
. If you think this is a rustc bug please let me know and I'll report this in to rustc issue tracker. The problem exists in nightly as well.
I have this simple build script: https://github.com/osa1/sg/blob/master/build.rs it runs cc
6 times in total. The generated files should be statically linked with the executable.
In each iteration the build script runs cc
twice. The second file being compiled uses symbols defined in the first.
cargo build
works fine with rustc 1.60. With 1.61 it fails with "undefined reference to xyz" build errors where the symbols in error messages are symbols defined in the first file and used in the second file.
When both of the files being compiled are C files, I can combine the two cc
commands in the loop body with one, passing both files as inputs. If I do that the build script works fine with rustc 1.61.
However sometimes one of the files is a C++ file, and in that case I can't combine these two cc
commands into one, so I can't fix this for rustc 1.61 and newer by compiling both files in one invocation of cc
.
Should cc
be updated for some change in rustc 1.61? I checked the changelog for 1.61. The only entry that looks somewhat relevant is rust-lang/rust#93901. However from that thread I don't see why it would break a build script that works fine with rustc 1.61..
Activity
osa1 commentedon Jul 22, 2022
This is so strange.. If I swap the
cc
calls it works. So instead of building the dependency and then the dependant (which works in rustc older than 1.61), I build the dependant first and then the dependency.Swap cc command order in build script
Wilfred commentedon Aug 28, 2022
Note that rust 1.61 uses
whole-archive
linking in fewer cases, so linking has changed: https://github.com/rust-lang/rust/blob/1.61.0/RELEASES.md#compatibility-notes