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

Fix CMake Windows system library deps #6980

Merged
merged 3 commits into from
Apr 17, 2020

Conversation

fooishbar
Copy link
Contributor

These three commits fix linking of system libraries when declared as dependencies of CMake targets we pick up as Meson dependencies. In particular, when linking Clang into Mesa via CMake, we were dropping all of the system library dependencies such as ole32 and uuid … except if Meson was executed from the source directory, in which case we would retain version as a bare argument (since the Mesa source root has a file called VERSION), which would get passed through to the linker without a suffix qualification and fail the build.

This PR attempts to do something more reasonable with system-library dependencies under Windows.

cc @dcbaker @jenatali

Copy link
Member

@mensinda mensinda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about Windows to comment if the fundamental approach is correct, but I do have some general nitpicks with this PR:

mesonbuild/dependencies/base.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/base.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/base.py Outdated Show resolved Hide resolved
@fooishbar
Copy link
Contributor Author

The three CI failures (checkarg failing in a cross-compilation environment which doesn't use CMake, increased Clang 10.x strictness on Windows) all seem unrelated.

@mensinda
Copy link
Member

Yes, these CI failures are currently a know issue.

@fooishbar fooishbar force-pushed the cmake-windows-system-lib-deps branch from dd26711 to 6108832 Compare April 15, 2020 13:32
Copy link
Member

@mensinda mensinda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mesonbuild/dependencies/base.py Outdated Show resolved Hide resolved
@fooishbar fooishbar force-pushed the cmake-windows-system-lib-deps branch from 6108832 to b485144 Compare April 15, 2020 20:08
mesonbuild/dependencies/base.py Outdated Show resolved Hide resolved
When finding dependencies from CMake, use a smarter regex to determine
whether or not a dependency is actually a link argument, and pass
through Windows link arguments properly.
On Windows, library dependencies can be passed with no prefix or suffix;
rather than -lfoo or foo.dll, they can just be passed as 'foo'.

CMake handles this and suffixes the library with '.lib' or '.dll',
depending on the link mode.

Do the same here, and if we've been passed an unqualified non-option
bare name on Windows, add the appropriate suffix and pass it through to
the linker. This fixes dependencies on system libraries.
When taking library dependencies from CMake, we first attempt to look
the dependency up in the target list, then fall back to treating it as a
path, which we add if the path exists.

As there is no check for whether or not the path is really a path, this
can cause false positives; for example if a 'uuid' dependency was passed
intending to be a target, but it cannot be found and the current
directory also contains a file or directory named 'uuid', we will just
include the string 'uuid' in library dependencies.

This is particularly prevalent on Windows, where a system library called
'version' exists, and thanks to case insensitivity will match a file
called 'VERSION' if found in the source root when running Meson from the
source directory, or a generated file when running Meson from the build
directory.

Fix this check to only look up filesystem existence on absolute paths,
not unqualified.

This also adds a fallback warning in case an argument cannot be found,
rather than silently falling back.
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

Successfully merging this pull request may close these issues.

None yet

4 participants