Meson relinks shared libraries and drops linker settings #13586
Replies: 1 comment 1 reply
-
Reconfiguring is a logical and reasonable outcome of "updating the meson.build files" -- if you have added additional targets, for example, those need to be calculated and added into the build. They may for example be mandatory in order to successfully re-compile targets whose source *.c files got updated too. Building 38 targets even though nothing has changed is also a logical and reasonable outcome of ninja believing that something has, in fact, changed. Something has to have changed, because ninja calculates whether to rebuild the targets by checking whether the link command has changed. So if the link command changes, the target is rebuilt *with the new link command. ... What this question therefore boils down to is, why after running |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if this is a meson bug or if I am just not understanding how this works properly.
Following on from gh-13046 I have the following in meson.build:
The idea is that I set
-Dadd_flint_rpath=true
and then meson will set the rpath entries in the shared libraries so that they can find my local build oflibflint.so
when I run the tests in a development checkout on Linux.This works fine but fails mysteriously when meson automatically reconfigures itself. Specifically I run the following commands:
This sets up a nice new build directory, sets pkgconfig to find libflint.so and tells meson to install the rpaths cia the linker args. Then
spin test
runs the tests and everything works. If I edit the code and returnmeson compile
orspin test
etc I get a nice incremental rebuild and the tests run.If after the above command I just run meson compile again then I get this:
However if I touch the
meson.build
file then something else happens:Notice that it didn't just reconfigure. It also built 38 targets with the linker.
Now
spin test
fails because the rpaths are not set any more:I don't quite understand what happens after
touch meson.build
. It seems meson observes the timestamp on the file and decides to reconfigure itself which I guess is fine but then it decides to build 38 targets even though nothing has changed. A full build has 114 targets which is because there are 38 extension modules and each has 3 build steps:The 38 targets that got rebuilt are all the linking step
.o -> .so
.So for some reason meson decided to relink everything even though nothing changed. And it also didn't use my linker args properly somehow. Now if I touch meson.build again then I get:
So this time it does not think that anything needs to be linked. However the linked files are still broken and don't have the rpath. The only way I have found to get it working again from this state is with
--wipe
(orrm -r build
).When meson compiles it uses these arguments in the linking step:
So the command lines are not exactly the same. The first one has these:
Whereas the second one has
The argument that I told it to add is missing on the second run. I'm not sure what the other arguments are for given that they don't actually result in the rpath being set. More generally I don't understand why the arguments would just be the same in both cases.
Is this a meson bug?
Maybe meson gets confused because one path has
build/..
which after normalisation makes it equivalent to the other path?Is there a better way of getting the rpaths set? The problem is really just that
meson install
strips out the rpaths during install and I don't want it to do that.Beta Was this translation helpful? Give feedback.
All reactions