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

__json_c_strerror incompatibility with link-time optimization #357

Closed
lhunath opened this issue Aug 31, 2017 · 4 comments
Closed

__json_c_strerror incompatibility with link-time optimization #357

lhunath opened this issue Aug 31, 2017 · 4 comments

Comments

@lhunath
Copy link

lhunath commented Aug 31, 2017

When enabling -flto, the __json_c_strerror symbol appears to exhibit issues. I'm not sure I fully understand the error, though.

  CCLD     test_util_file
  CCLD     test_float
  CCLD     test1
  CCLD     test2
ld: reference to symbol (which has not been assigned an address) __json_c_strerror in '_json_c_get_random_seed' from /tmp/lto.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test1] Error 1
make[2]: *** Waiting for unfinished jobs....
@hawicz
Copy link
Member

hawicz commented Sep 2, 2017

Maybe try a "make V=1 check" to see what command it's actually running, then check that the libjson-c it's linking in is the correct one, with that symbol present.

@lhunath
Copy link
Author

lhunath commented Sep 2, 2017

libtool: link: gcc -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.8 -O2 -g -flto -Wall -Werror -Wcast-qual -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -D_GNU_SOURCE -D_REENTRANT -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.8 -flto -o test2 test2.o  ../.libs/libjson-c.a

Relevant output of nm -m .libs/libjson-c.a:

random_seed.o:
                 (undefined) external ___error
                 (undefined) external ___stderrp
                 (undefined) external __json_c_strerror
                 (undefined) external _close
                 (undefined) external _exit
                 (undefined) external _fprintf
---------------- (LTO,CODE) external _json_c_get_random_seed
                 (undefined) external _open
                 (undefined) external _read
                 (undefined) external _stat$INODE64
                 (undefined) external _time

strerror_override.o:
---------------- (LTO,CODE) external __json_c_strerror
---------------- (LTO,DATA) external __json_c_strerror_enable
---------------- (LTO,DATA) non-external _errno_buf
---------------- (LTO,RODATA) non-external _errno_list

@hawicz
Copy link
Member

hawicz commented Sep 4, 2017

Looks like it should be able to find it. Just a guess, but perhaps it's being picky about the order: try adjusting the Makefile.am so strerror_override.c is listed early in libjson_c_la_SOURCES, and ends up early in the .a file?

@hawicz
Copy link
Member

hawicz commented Oct 10, 2017

I tried turning on LTO on a Debian Jessie (8) box, with gcc 4.9.2, and it worked fine there with no errors or warnings (once I hacked around some things to get it to use gcc-ar and gcc-ranlib). If there's something we can change to make this work for you, let me know and re-open this issue.

@hawicz hawicz closed this as completed Oct 10, 2017
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

No branches or pull requests

2 participants