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

Cannot link librsvg static library #23772

Closed
jeroen opened this Issue Feb 6, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@jeroen
Copy link
Contributor

jeroen commented Feb 6, 2018

  • Confirmed this is a problem with brew installing one, specific Homebrew/homebrew-core formula (not cask or tap) and not every time you run brew? If it's a general brew problem please file this issue at https://github.com/Homebrew/brew/issues/new. If it's a brew cask problem please file this issue at https://github.com/caskroom/homebrew-cask/issues/new. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed all issues and retried your prior step?
  • Ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • If brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

As of the most recent update the static library for librsvg is broken. Linking it fails with:

ld: warning: ignoring file /usr/local/lib/librsvg-2.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/lib/librsvg-2.a

And then the application fails to load:

Unable to load shared object 
  dlopen(app.so, 6): Symbol not found: _rsvg_handle_close

I have reproduced this using the bottled librsvg-2.a on both sierra and el-capitain.

@jeroen jeroen changed the title librsvg static library built for wrong architecture Cannot link librsvg static library Feb 6, 2018

@fxcoudert

This comment has been minimized.

Copy link
Member

fxcoudert commented Feb 6, 2018

The static library contains 64-bit object files (x86_64), as is expected.

$ file /usr/local/Cellar/librsvg/2.42.2/lib/librsvg-2.dylib 
/usr/local/Cellar/librsvg/2.42.2/lib/librsvg-2.dylib: Mach-O 64-bit dynamically linked shared library x86_64
$ ar -x /usr/local/Cellar/librsvg/2.42.2/lib/librsvg-2.a librsvg_2_la-rsvg-base-file-util.o
$ file librsvg_2_la-rsvg-base-file-util.o 
librsvg_2_la-rsvg-base-file-util.o: Mach-O 64-bit object x86_64

Please provide the output of brew info librsvg, brew doctor, and tell us what you are trying to compile against this library.

@jeroen

This comment has been minimized.

Copy link
Contributor

jeroen commented Feb 6, 2018

This happens for all applications that statically link against librsvg, on all my systems. It does not happen for the previous version /usr/local/Cellar/librsvg/2.40.20/.

Below is a minimal example. The following test.c file:

#include <librsvg/rsvg.h>
int main(){
  RsvgHandle *svg = rsvg_handle_new_from_data (NULL, 0, NULL);
}

And then link it to the static library:

gcc test.c $(pkg-config --cflags librsvg-2.0) /usr/local/lib/librsvg-2.a

Will give you:

ld: warning: ignoring file /usr/local/lib/librsvg-2.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/lib/librsvg-2.a
Undefined symbols for architecture x86_64:
  "_rsvg_handle_new_from_data", referenced from:
@fxcoudert

This comment has been minimized.

Copy link
Member

fxcoudert commented Feb 6, 2018

Confirmed. I do not see why, because the objects files I probed inside the archive are x86_64…

@jeroen

This comment has been minimized.

Copy link
Contributor

jeroen commented Feb 6, 2018

I think what's tripping up the linker is that the static library contains yet another static library called librsvg_internals.a. I'm not sure if this is intended:

ar -t /usr/local/Cellar/librsvg/2.42.2/lib/librsvg-2.a
__.SYMDEF SORTED
librsvg_internals.a
librsvg_2_la-librsvg-enum-types.o
librsvg_2_la-librsvg-features.o
librsvg_2_la-rsvg-base-file-util.o
librsvg_2_la-rsvg-base.o
...

This was not the case for the previous version:

Jeroens-MacBook-Pro:Desktop jeroen$ ar -t /usr/local/Cellar/librsvg/2.40.20/lib/librsvg-2.a
__.SYMDEF SORTED
librsvg_2_la-librsvg-features.o
librsvg_2_la-rsvg-css.o
librsvg_2_la-rsvg-defs.o
librsvg_2_la-rsvg-image.o
librsvg_2_la-rsvg-io.o
librsvg_2_la-rsvg-paint-server.o
librsvg_2_la-rsvg-path.o
librsvg_2_la-rsvg-base-file-util.o
...
@fxcoudert

This comment has been minimized.

Copy link
Member

fxcoudert commented Feb 6, 2018

It seems like an upstream bug to me… not something we do specifically for Homebrew.

@jeroen

This comment has been minimized.

Copy link
Contributor

jeroen commented Feb 6, 2018

@federicomenaquintero could this be a bug in librsvg?

@federicomenaquintero

This comment has been minimized.

Copy link

federicomenaquintero commented Feb 6, 2018

This is https://gitlab.gnome.org/GNOME/librsvg/issues/159 upstream. In general, the --disable-shared option for the configure script is broken.

I have no idea how to make libtool do the right thing about this :(

@federicomenaquintero

This comment has been minimized.

Copy link

federicomenaquintero commented Feb 7, 2018

I've just asked about this to automake@gnu.org - we'll see what happens.

@fxcoudert

This comment has been minimized.

Copy link
Member

fxcoudert commented Feb 8, 2018

Closing this issue here, as it is tracked upstream and is not Homebrew-specific. Thanks for the report and follow-up!

@fxcoudert fxcoudert closed this Feb 8, 2018

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.