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

linker warning on macOS Xcode 14 ld: warning: -undefined dynamic_lookup may not work with chained fixups #20381

Closed
skaji opened this issue Oct 9, 2022 · 2 comments
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 distro-darwin Needs Triage

Comments

@skaji
Copy link
Contributor

skaji commented Oct 9, 2022

Description

On macOS, Configure script tries to set -undefined dynamic_lookup for lddlflags:

lddlflags="${ldflags} -bundle -undefined dynamic_lookup"

But, if you use Xcode 14, it emits the following linker warning:

ld: warning: -undefined dynamic_lookup may not work with chained fixups

Steps to Reproduce

My environment is

❯ sw_vers
ProductName:	macOS
ProductVersion:	12.5
BuildVersion:	21G72

❯ cc --version
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Then

❯ wget https://www.cpan.org/src/5.0/perl-5.36.0.tar.gz
❯ tar xf perl-5.36.0.tar.gz
❯ cd perl-5.36.0

❯ ./Configure -des
...
Any special flags to pass to cc to create a dynamically loaded library?
[ -mmacosx-version-min=12.5 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong]
...

❯ make
...
cc  -mmacosx-version-min=12.5 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong  B.o  -o ../../lib/auto/B/B.bundle  \
	      \

ld: warning: -undefined dynamic_lookup may not work with chained fixups
...
cc  -mmacosx-version-min=12.5 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong  Bzip2.o blocksort.o bzlib.o compress.o crctable.o decompress.o huffman.o randtable.o   -o ../../lib/auto/Compress/Raw/Bzip2/Bzip2.bundle  \
	      \

ld: warning: -undefined dynamic_lookup may not work with chained fixups
...

Expected behavior

No warning.

Perl configuration

perl -V
Summary of my perl5 (revision 5 version 36 subversion 0) configuration:
   
  Platform:
    osname=darwin
    osvers=21.6.0
    archname=darwin-2level
    uname='darwin mbp2019.local 21.6.0 darwin kernel version 21.6.0: sat jun 18 17:07:25 pdt 2022; root:xnu-8020.140.41~1release_x86_64 x86_64 '
    config_args='-des -Dprefix=/Users/skaji/env/plenv/versions/5.36.0_xcode14 -Dscriptdir=/Users/skaji/env/plenv/versions/5.36.0_xcode14/bin -Dman1dir=none -Dman3dir=none'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=12.5 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=12.5 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='Apple LLVM 14.0.0 (clang-1400.0.29.102)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=12.5 -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /usr/lib
    libs=-lgdbm
    perllibs=
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=12.5 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under darwin
  Compiled at Oct 10 2022 00:03:44
  @INC:
    /Users/skaji/env/plenv/versions/5.36.0_xcode14/lib/perl5/site_perl/5.36.0/darwin-2level
    /Users/skaji/env/plenv/versions/5.36.0_xcode14/lib/perl5/site_perl/5.36.0
    /Users/skaji/env/plenv/versions/5.36.0_xcode14/lib/perl5/5.36.0/darwin-2level
    /Users/skaji/env/plenv/versions/5.36.0_xcode14/lib/perl5/5.36.0

See also
bazelbuild/bazel#16413
python/cpython#97524
ruby/ruby#6193
https://issues.guix.gnu.org/issue/57849

@jkeenan jkeenan added build-time-warnings Replaces [META] Build-time warnings RT #133556 distro-darwin and removed distro-darwin labels Oct 9, 2022
@Leont
Copy link
Contributor

Leont commented Oct 10, 2022

-bundle_loader <executable> might fix it, but may not always work when libraries are involved? (more information needed).

--linkopt=-Wl,-no_fixup_chains should work for now, but given it's undocumented and apple seems to want to move to this brave new world that may not keep working.

Or we can suppress linker warnings (-Wl,-w), which seems like a terrible idea but apparently emacs is getting away with it.

What a mess.

@skaji
Copy link
Contributor Author

skaji commented Apr 11, 2023

It seems that linkers do not emit warnings anymore in the following environment:

❯ sw_vers
ProductName:		macOS
ProductVersion:		13.1
BuildVersion:		22C65

❯ cc --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 distro-darwin Needs Triage
Projects
None yet
Development

No branches or pull requests

3 participants