boludoz / lz4

Automatically exported from code.google.com/p/lz4
Other
0 stars 0 forks source link

soname option not recognized on OSX gcc #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run "make" 

What is the expected output? What do you see instead?

$ make
gcc -O3 -c -arch x86_64 -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"r113\" 
lz4.c lz4hc.c
ar rcs liblz4.a lz4.o lz4hc.o
gcc -shared -fPIC -Wl,--soname=liblz4.so.1 -arch x86_64 -I. -std=c99 -Wall -W 
-Wundef -DLZ4_VERSION=\"r113\" lz4.c lz4hc.c -o liblz4.so
ld: unknown option: --soname=liblz4.so.1
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [liblz4.so] Error 1

What version of the product are you using? On what operating system?

Mac OS X 10.9.1 
$gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr 
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

Please provide any additional information below.

Replacing the "soname" option to gcc with "install_name" allows successful 
compilation:

gcc -shared -fPIC -Wl,-install_name,liblz4.so.1 -arch x86_64 -I. -std=c99 -Wall 
-W -Wundef -DLZ4_VERSION=\"r113\" lz4.c lz4hc.c -o liblz4.so

Original issue reported on code.google.com by bsg...@gmail.com on 14 Feb 2014 at 4:19

GoogleCodeExporter commented 9 years ago
ok, so your gcc is in fact clang ?

Original comment by yann.col...@gmail.com on 14 Feb 2014 at 6:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Apparently, as installed by the latest XCode command line tools. 

Original comment by bsg...@gmail.com on 15 Feb 2014 at 7:27

GoogleCodeExporter commented 9 years ago
ok, 
unfortunately -install_name is not accepted by GCC.

So it's not a portable solution.
There's a need to find another one which does not affect GCC users.

Original comment by yann.col...@gmail.com on 27 Feb 2014 at 7:28

GoogleCodeExporter commented 9 years ago
According to this S.O. post 
(http://stackoverflow.com/questions/9170000/how-use-llvm-linker)

the following makefile line should work :
gcc -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"r114\" -shared lz4.c lz4hc.c 
-fPIC -Wl,-soname=liblz4.so.1 -o liblz4.so

I could test is using clang on Linux, and it works correctly :
clang -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"r114\" -shared lz4.c 
lz4hc.c -fPIC -Wl,-soname=liblz4.so.1 -o liblz4.so

which is no proof that it will work on OSX.

Would you mind testing it ?

Regards

Original comment by yann.col...@gmail.com on 27 Feb 2014 at 7:40

GoogleCodeExporter commented 9 years ago
According to this S.O. post 
(http://stackoverflow.com/questions/9170000/how-use-llvm-linker)

the following makefile line should work :
gcc -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"r114\" -shared lz4.c lz4hc.c 
-fPIC -Wl,-soname=liblz4.so.1 -o liblz4.so

I could test is using clang on Linux, and it works correctly :
clang -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"r114\" -shared lz4.c 
lz4hc.c -fPIC -Wl,-soname=liblz4.so.1 -o liblz4.so

which is no proof that it will work on OSX.

Would you mind testing it ?

Regards

Original comment by yann.col...@gmail.com on 27 Feb 2014 at 7:40

GoogleCodeExporter commented 9 years ago
Latest r114 might solve this issue, although I'm unable to test it properly.
At least, the new makefile is compatible with clang (on Linux).

Original comment by yann.col...@gmail.com on 12 Mar 2014 at 2:58

GoogleCodeExporter commented 9 years ago
I tested the r114 release on OS X 10.8. The problem persists. I was able to get 
liblz4 to compile by conditionally removing the -soname linker argument. 
Additionally, I set the extension of shared library files to dylib instead of 
so. The patch is attached. Please test it and let me know if it solves the 
problem.

Original comment by jasiec...@gmail.com on 14 Mar 2014 at 6:26

Attachments:

GoogleCodeExporter commented 9 years ago
For reference: -soname isn't recognized by OS X's linker. This isn't a clang 
vs. GCC problem. -install_name is the OS X equivalent, though -install_name 
typically takes the install path rather than a basename.

Original comment by mistyde...@gmail.com on 14 Mar 2014 at 6:43

GoogleCodeExporter commented 9 years ago

Original comment by yann.col...@gmail.com on 20 Mar 2014 at 1:45

GoogleCodeExporter commented 9 years ago

Original comment by yann.col...@gmail.com on 20 Mar 2014 at 1:46

GoogleCodeExporter commented 9 years ago
I've adapted your proposed patch to latest r115 release candidate.

It seems to be a very good patch.
Unfortunately, I'm unable to test it on OS-X.
All I can say is that it works fine on Linux, and doesn't break anything.
So I'm relying on you for OS-X related tests.

Best Regards

Original comment by yann.col...@gmail.com on 20 Mar 2014 at 1:58

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed into r115

Original comment by yann.col...@gmail.com on 23 Mar 2014 at 11:16

GoogleCodeExporter commented 9 years ago
I just tested it on OS X. It compiles correctly but it still builds 
`liblz4.dylib.1.2.3` instead of `liblz4.1.2.3.dylib`.

Original comment by jasiec...@gmail.com on 23 Mar 2014 at 12:15

GoogleCodeExporter commented 9 years ago
true, there's a need for a more complex patch to correct this issue

Original comment by yann.col...@gmail.com on 23 Mar 2014 at 12:17

GoogleCodeExporter commented 9 years ago
The following release candidate should correct the issue regarding OSX 
versioned naming convention for shared library.

Original comment by yann.col...@gmail.com on 23 Mar 2014 at 1:36

Attachments:

GoogleCodeExporter commented 9 years ago
Great, it seems to work very well now! Thanks for addressing it so quickly.

Original comment by jasiec...@gmail.com on 23 Mar 2014 at 3:49

GoogleCodeExporter commented 9 years ago
fix integrated into r116

Original comment by yann.col...@gmail.com on 24 Mar 2014 at 9:02

GoogleCodeExporter commented 9 years ago
Great, thank you! Consider putting a link to the Homebrew lz4 formula in the 
"Executable binaries" section on the main project page:

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/lz4.rb

It allows Mac OS X users to install lz4 by simply running `brew install lz4`. 
So far it's r114 but a patch updating it to r116 is on its way.

Original comment by jasiec...@gmail.com on 25 Mar 2014 at 8:09

GoogleCodeExporter commented 9 years ago
sure

Original comment by yann.col...@gmail.com on 25 Mar 2014 at 9:14