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

find_library finds library even when it shouldn't #13142

Open
pobrn opened this issue Apr 25, 2024 · 0 comments
Open

find_library finds library even when it shouldn't #13142

pobrn opened this issue Apr 25, 2024 · 0 comments

Comments

@pobrn
Copy link
Contributor

pobrn commented Apr 25, 2024

Describe the bug

Library is found when it shouldn't be found.

To Reproduce

I am using musl-gcc from the musl Arch Linux package with the following cross file:

[binaries]
c = 'musl-gcc'
strip = 'strip'

[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

Consider the following project:

project('test', 'c')
meson.get_compiler('c').find_library('readline')

Configuring the project shows:

Library readline found: YES

but the log shows:

Running compile:
Working directory:  /tmp/a/build/meson-private/tmpjlv80j04
Code:
 int main(void) { return 0; }

-----------
Command line: `musl-gcc /tmp/a/build/meson-private/tmpjlv80j04/testfile.c -o /tmp/a/build/meson-private/tmpjlv80j04/output.exe -D_FILE_OFFSET_BITS=64 -O0 -lreadline -Wl,--allow-shlib-undefined` -> 1
stderr:
/usr/bin/ld: cannot find -lreadline: No such file or directory
collect2: error: ld returned 1 exit status
[...]
Library readline found: YES

I am seeing this in the logs:

Command line: `musl-gcc /tmp/a/build/meson-private/tmpyokmfld7/testfile.c -o /tmp/a/build/meson-private/tmpyokmfld7/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 --print-search-dirs` -> 0
stdout:
install: /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/
programs: =/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/bin/
libraries: =/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/lib/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../x86_64-pc-linux-gnu/13.2.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib/:/lib/x86_64-pc-linux-gnu/13.2.1/:/lib/../lib/:/usr/lib/x86_64-pc-linux-gnu/13.2.1/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../:/lib/:/usr/lib/
-----------

so it seems to me that musl-gcc prints the wrong library search paths and that's why meson thinks the library exists? Why does meson not believe the result of the actual compilation with -lreadline? Or am I holding the cross file wrong somehow?

Expected behavior

The library is not found.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? cross
  • what Python version are you using: 3.11.8
  • what meson --version: 1.4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant