flex icon indicating copy to clipboard operation
flex copied to clipboard

Build on Apple Silicon fails due to missing linker options

Open ilg-ul opened this issue 4 years ago • 10 comments

Building on new Macs fails with:

make[2]: Entering directory '/Users/ilg/Work/xbb-bootstrap-3.4-macos-11.6.1-arm64/build/flex-2.6.4/src'

/bin/bash ../libtool  --tag=CC   --mode=link clang  -pipe -O2 -ffunction-sections -fdata-sections -w -version-info 2:0:0 -L/Users/ilg/.local/xbb-bootstrap/lib  -Wl,-dead_strip -o libfl.la -rpath /Users/ilg/.local/xbb-bootstrap/lib libmain.lo libyywrap.lo  -lm 

Undefined symbols for architecture arm64:
  "_yylex", referenced from:
      _main in libmain.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [Makefile:736: libfl.la] Error 1
make[2]: Leaving directory '/Users/ilg/Work/xbb-bootstrap-3.4-macos-11.6.1-arm64/build/flex-2.6.4/src'
make[1]: *** [Makefile:577: all] Error 2

One of the reasons is the missing linker -Wl,-undefined -Wl,dynamic_lookup, skipped due to a problem in configure.

HomeBrew applies a patch to avoid this:

ilg-ul avatar Nov 27 '21 16:11 ilg-ul

The patch that the linked file points to is against configure itself. Can you point me to a patch that provides the fix in configure.ac (or some other input to configure)? Alternatively, if this is addressed in a more recent version of autoconf, then can you suggest how recent that would need to be?

Another thing worth checking is if this problem occurs on the tip of master.

Thanks!

westes avatar Nov 27 '21 18:11 westes

a patch that provides the fix in configure.ac

I tried to figure out what is wrong in configure.ac, but failed. :-(

a more recent version of autoconf

Ah, right, I'm using the very latest autoconf/automake. This creates another set of problems, since the current configure refers to aclocal-1.15, and the new versions provide aclocal-1.16.

if this problem occurs on the tip of master

Yeah, this is a bit more complicated, but I'll try to find a way to do it. Releases would make things easier.

ilg-ul avatar Nov 27 '21 18:11 ilg-ul

Can you document which versions of:

  • autoconf
  • automake
  • libtool you're seeing this error with?

westes avatar Nov 27 '21 18:11 westes

  • autoconf 2.71
  • automake 1.16.5
  • libtool 2.4.6

ilg-ul avatar Nov 27 '21 19:11 ilg-ul

I cloned the master branch, ran autogen.sh and observed the same behaviour.

In case it helps, attached are the generated files.

autogen.zip

The problem seems to be in configure, around lines 7970, where it probably fails to identify the kernel version, which is now 20.x, and silently leaves _lt_dar_allow_undefined uninitialised.

ilg-ul avatar Nov 28 '21 06:11 ilg-ul

The root cause is in the venerable libtool, which handles the *_allow_undefined variables.

HomeBrew patches it to fix the linker options:

ilg-ul avatar Nov 28 '21 07:11 ilg-ul

I patched configure as in HomeBrew and the build passed, but later the checks failed, with an internal error caused by gm4; without providing more details in the logs, further diagnosing is difficult.

flex-2.6.4-logs.zip

ilg-ul avatar Nov 28 '21 08:11 ilg-ul

Can you point me to a patch that provides the fix in configure.ac (or some other input to configure)? Alternatively, if this is addressed in a more recent version of autoconf, then can you suggest how recent that would need to be?

It is libtool bug 44605. A fixed version of libtool has not yet been released. When it is, regenerate the configure script with that version.

ryandesign avatar Jan 14 '22 08:01 ryandesign

Does libtool 2.47 fix this?

westes avatar Mar 27 '22 00:03 westes

I certainly expect 2.4.7 to fix it. I haven't updated yet but they did commit the fix months before releasing 2.4.7.

ryandesign avatar Mar 27 '22 00:03 ryandesign