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

Don't pass --allow-shlib-undefined to lld if it's not supported #5912

Merged

Conversation

Akaricchi
Copy link
Contributor

Fixes builds with llvm-mingw

def get_allow_undefined_args(self) -> typing.List[str]:
if self.has_allow_shlib_undefined:
return self._apply_prefix('--allow-shlib-undefined')
return []
Copy link
Member

Choose a reason for hiding this comment

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

looking at the LLVM code --allow-shlib-undefined has been implemented for ELF (so Linux, *BSD, etc) for a long time, but isn't implemented for PE/COFF. So we should do one of two things here:

  1. Push the has_link_argument method into the DynamicLinker class and invoke that instead of opencoding it with Popen.
  2. Add the MachineInfo class into the Linker like Remove compiler type #5833 does and do somehting like:
if self.info.is_windows():
    return []
return self._apply_prefix('--allow-shlib-undefined'

Copy link
Contributor Author

@Akaricchi Akaricchi Sep 10, 2019

Choose a reason for hiding this comment

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

I personally prefer the first approach. In general I think it's better to make less assumptions about available features.

I'll see if I can do that tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

ping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sorry, I got caught up in Taisei stuff. Now that we're done with a new release I'll go take a look into this now.

Copy link
Contributor Author

@Akaricchi Akaricchi Sep 30, 2019

Choose a reason for hiding this comment

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

Looks like this is basically implemented already; DynamicLinker has a has_multi_arguments method. Only problem is that it takes an Environment object, which I don't think is accessible in this context. I see a few other methods like get_soname_args and build_rpath_args take Environment as a parameter; would it be okay to do the same in get_allow_undefined_args? Is there any reason why we don't just instantiate linkers with a permanent reference to an Environment?

EDIT: nevermind the "already implemented" part. On closer inspection, it looks like no linker actually implements has_multi_arguments. I guess that's what @dcbaker was talking about.

Copy link
Member

Choose a reason for hiding this comment

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

looking at the LLVM code --allow-shlib-undefined has been implemented for ELF (so Linux, *BSD, etc) for a long time, but isn't implemented for PE/COFF.

I think it cannot be implemented for PE/COFF shared libraries, as they cannot contain undefined symbols (every imported symbol is resolved to a providing library at link time).

So any shared library which actually requires undefined symbols isn't going to be simply portable to PE/COFF (see test cases/common/121 shared module for an example of the required gymnastics)

However, since we don't mark shared libraries as having undefined symbols or not (c.f. libtool -no-undefined), I guess all we can do is not provide this flag where unsupported, and have the build fail on PE/COFF if it's actually needed.

@Akaricchi
Copy link
Contributor Author

Akaricchi commented Dec 7, 2019

Reviving this since it's still relevant

@dcbaker unfortunately it doesn't seem easy to move the has_link_argument logic into DynamicLinker. It's too tightly coupled with the Compiler class (at least in clike case). What I could do is pass the Compiler object to the linker's get_allow_undefined_args method, and have the linker call the compiler's has_link_argument there. It's a shitty hack, but it would work without forcing me to refactor half the codebase.

Edit: I realized that wouldn't work either, since the compiler doesn't have access to Environment :/

@textshell
Copy link
Contributor

Isn't --allow-shlib-undefined default on lld anyway? So maybe that allows to simplify this.

vlc-mirrorer pushed a commit to videolan/vlc that referenced this pull request Feb 14, 2020
…orted

From mesonbuild/meson#5912

This solves the -lpthread detection issue with libplacebo when compiling with
LLVM for Windows.
Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

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

I still don't like calling external binaries when we really do know that in the real work there's just elf, mach-o and pe/coff. But it's not the end of the world and I can fix this later if I really want to.

@dcbaker dcbaker merged commit 49ae886 into mesonbuild:master Feb 18, 2020
@xclaesse
Copy link
Member

This broke CI, s/typing/T/

vlc-mirrorer pushed a commit to videolan/vlc-3.0 that referenced this pull request Jun 18, 2020
…orted

From mesonbuild/meson#5912

This solves the -lpthread detection issue with libplacebo when compiling with
LLVM for Windows.

(cherry picked from commit f079504ccf7ec7ba0156adf962815dfa7da01aea)

Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
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

6 participants