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 the build with slibtool. #31

Merged
merged 2 commits into from Apr 12, 2021
Merged

Fix the build with slibtool. #31

merged 2 commits into from Apr 12, 2021

Conversation

orbea
Copy link
Contributor

@orbea orbea commented Apr 9, 2021

When building libspiro with slibtool (https://dev.midipix.org/cross/slibtool) it fails in two places.

rdlibtool --tag=CC --mode=link gcc -Wall -Wextra -Wcast-align -Wbad-function-cast -Wc++-compat -Wmissing-prototypes -Wunused -Wdeprecated-declarations -g -O2 -Wall -Wextra -Wcast-align -Wbad-function-cast -Wc++-compat -Wmissing-prototypes -Wunused -Wdeprecated-declarations -no-undefined --mode=link -version-info 1:1:0 -o libspiro.la -rpath /usr/local/lib spiro.lo bezctx.lo spiroentrypoints.lo -lm

rdlibtool: lconf: {.name="libtool"}.
rdlibtool: fdcwd: {.fdcwd=AT_FDCWD, .realpath="/tmp/libspiro"}.
rdlibtool: lconf: fstatat(AT_FDCWD,".",...) = 0 {.st_dev = 45, .st_ino = 196675}.
rdlibtool: lconf: openat(AT_FDCWD,"libtool",O_RDONLY,0) = 3.
rdlibtool: lconf: found "/tmp/libspiro/libtool".
rdlibtool: link: x86_64-pc-linux-gnu-ar crs .libs/libspiro.a .libs/spiro.o .libs/bezctx.o .libs/spiroentrypoints.o
rdlibtool: link: gcc .libs/spiro.o .libs/bezctx.o .libs/spiroentrypoints.o -Wall -Wextra -Wcast-align -Wbad-function-cast -Wc++-compat -Wmissing-prototypes -Wunused -Wdeprecated-declarations -g -O2 -Wall -Wextra -Wcast-align -Wbad-function-cast -Wc++-compat -Wmissing-prototypes -Wunused -Wdeprecated-declarations --mode=link -lm -shared -fPIC -Wl,--no-undefined -Wl,-soname -Wl,libspiro.so.1 -o .libs/libspiro.so.1.0.1
gcc: error: unrecognized command-line option ‘--mode=link’
rdlibtool: exec error upon slbt_exec_link_create_library(), line 1566: (see child process error messages).
rdlibtool: < returned to > slbt_exec_link(), line 1996.
make[1]: *** [Makefile:532: libspiro.la] Error 2
make[1]: Leaving directory '/tmp/libspiro'
make: *** [Makefile:672: install-recursive] Error 1
rdlibtool --tag=CC --mode=link gcc -I.. -I.. -lm -g -O2 -o call-test0 call-test0.o ../.libs/libspiro.la -lm

rdlibtool: lconf: {.name="libtool"}.
rdlibtool: fdcwd: {.fdcwd=AT_FDCWD, .realpath="/tmp/libspiro/tests"}.
rdlibtool: lconf: fstatat(AT_FDCWD,".",...) = 0 {.st_dev = 45, .st_ino = 196774}.
rdlibtool: lconf: openat(AT_FDCWD,"libtool",O_RDONLY,0) = -1 [ENOENT].
rdlibtool: lconf: openat(AT_FDCWD,"../",O_DIRECTORY,0) = 3.
rdlibtool: lconf: fstat(3,...) = 0 {.st_dev = 45, .st_ino = 196675}.
rdlibtool: lconf: openat(3,"libtool",O_RDONLY,0) = 4.
rdlibtool: lconf: found "/tmp/libspiro/libtool".
rdlibtool: error logged in slbt_get_deps_meta(), line 126: path not found: ../.libs/.libs/libspiro.a.slibtool.deps.
rdlibtool: < returned to > slbt_exec_link_create_executable(), line 1617.
rdlibtool: < returned to > slbt_exec_link(), line 2062.
make[1]: *** [Makefile:718: call-test0] Error 2
make[1]: Leaving directory '/tmp/libspiro/tests'
make: *** [Makefile:675: install-recursive] Error 1

This reveals four issues:

  1. The build should not use --mode=link unless its also calling $(LIBTOOL) manually which its not. GNU libtool silently consumes and ignores invalid command-line arguments hiding the issue.
  2. The build should link dependencies with LIBADD for libraries or LDADD for programs while LDFLAGS is for other linker arguments. GNU libtool is far more permissive about these things than slibtool and hides incorrect usage.
  3. The header dependencies should be in SOURCES and the build should not define object files rules manually.
  4. The .libs directory should not be manually added to the linker paths, that is for internal $(LIBTOOL) usage.

Also please see this related PR fontforge/libuninameslist#24.

This fixes two issues:

1. The build should not specify --mode= unless it also calling
   $(LIBTOOL) manually.
2. The build should use LIBADD for linker flags instead of LDFLAGS.
@orbea
Copy link
Contributor Author

orbea commented Apr 9, 2021

Also, just so you know, GNU libtool silently ignores -no-undefined while slibtool does not, its a common way programs fail. Thankfully it seems libspiro doesn't have hidden undefined references. :)

@JoesCat JoesCat merged commit 2bd1e60 into fontforge:master Apr 12, 2021
@JoesCat
Copy link
Contributor

JoesCat commented Apr 12, 2021

Thanks for taking the time to check and fix this to work with slibtool

@orbea orbea deleted the libtool branch April 12, 2021 04:11
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

2 participants