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

Having trouble getting b2sum to compile on OS X #25

Closed
grempe opened this issue Jun 14, 2016 · 9 comments
Closed

Having trouble getting b2sum to compile on OS X #25

grempe opened this issue Jun 14, 2016 · 9 comments

Comments

@grempe
Copy link

grempe commented Jun 14, 2016

I cannot get b2sum to compile on OS X (10.11.5 El Capitan). If I use the OS X command line compile tools installed with Xcode I see:

$ make
cc b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c  -O3 -march=native -static -Werror=declaration-after-statement -std=c99 -I../sse -fopenmp  -o b2sum
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make: *** [all] Error 1

If I try to use homebrew installed gcc I get:

$ export CC=/usr/local/bin/gcc-6
$ make
/usr/local/bin/gcc-6 b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c  -O3 -march=native -static -Werror=declaration-after-statement -std=c99 -I../sse -fopenmp  -o b2sum
ld: library not found for -lcrt0.o
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

Is this a bug, or am I doing it wrong?

@noloader
Copy link
Contributor

Is this a bug, or am I doing it wrong?

This may be helpful: Creating static Mac OS X C build. Apparently, GCC does not support the configuration.

The trick to searching for this is to quote the library: "os x" brew ld: library not found for "-lcrt0.o". Otherwise, engines like Google think "all problems without the word lcrt0.o".

(My apologies for jumping in. The Mac port tools, like Macports and Brew, have caused me a fair amount of non-standard trouble over the years).

@sneves
Copy link
Member

sneves commented Jun 14, 2016

Removing the -fopenmp for Clang or the -static for GCC should work. With no -fopenmp you lose threading on `blake2xp``, but otherwise it should work fine.

@grempe
Copy link
Author

grempe commented Jun 16, 2016

Tried:

  1. CLANG : removing the -fopenmp and just running make FAILED
$ make
cc b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c  -O3 -march=native -static -Werror=declaration-after-statement -std=c99 -I../sse  -o b2sum
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
  1. GCC Removing the -static in line 5 WORKED!
$ export CC=/usr/local/bin/gcc-6

$ make
/usr/local/bin/gcc-6 b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c  -O3 -march=native -Werror=declaration-after-statement -std=c99 -I../sse -fopenmp  -o b2sum

$ ./b2sum b2sum
04ec985c5d05d773db9c40e32e280e922772d0170dae94eaa97d4f257ebabffdb817a195ef610b35fd68096d322f91a4d4f1320d8841e8b8ae88bd57ff075e80  b2sum
  1. CLANG : removing BOTH -static and -fopenmp and running make WORKED!
$ make
cc b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c  -O3 -march=native -Werror=declaration-after-statement -std=c99 -I../sse  -o b2sum

$ ./b2sum b2sum
00551e8de9a471c267300315df1193077f5f943a111a8b0890ed5a5870507655d63a5828ff0862765526b4f792db0bd3540ee9f320ed9e840c750261196d6fd0  b2sum

$ git diff
diff --git a/b2sum/makefile b/b2sum/makefile
index 8558b2b..52e047c 100644
--- a/b2sum/makefile
+++ b/b2sum/makefile
@@ -2,8 +2,8 @@ PROG=b2sum
 PREFIX?=/usr/local
 MANDIR?=$(PREFIX)/man
 CC?=gcc
-CFLAGS?=-O3 -march=native -static -Werror=declaration-after-statement
-CFLAGS+=-std=c99 -I../sse -fopenmp
+CFLAGS?=-O3 -march=native -Werror=declaration-after-statement
+CFLAGS+=-std=c99 -I../sse
 LIBS=
 #FILES=b2sum.c ../ref/blake2b-ref.c ../ref/blake2s-ref.c ../ref/blake2bp-ref.c ../ref/blake2sp-ref.c
 FILES=b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c

It would be great if the project would keep this issue open and modify the makefile so that it will remove those options when run on OS X if there are no major negatives to doing so.

Something along the lines of what is shown in this post might do the trick.

https://discussions.apple.com/thread/1945589?tstart=0

Thanks for the help.

@noloader
Copy link
Contributor

noloader commented Jun 16, 2016

Something along the lines of what is shown in this post might do the trick.
https://discussions.apple.com/thread/1945589?tstart=0

The tricks shown in the makefile require a portable make, like GNUmake or Dmake. I believe BLAKE2 uses Posix's make, which is anemic. Folks use often GNUmake or Dmake because Posix make is so anemic.

@grempe
Copy link
Author

grempe commented Jun 16, 2016

cc: @Scarletts

a559fae

@sneves
Copy link
Member

sneves commented Jun 19, 2016

5f2f566 disables -static, which wasn't really necessary, and makes -fopenmp optional with the NO_OPENMP flag. Use make NO_OPENMP=1 to build without it.

@grempe
Copy link
Author

grempe commented Jun 20, 2016

Thanks, make NO_OPENMP=1 works for me locally.

Perhaps this could be documented in a README.md in the b2sum dir for others? Unless you are very familiar with the nuances of the makefile most won't figure this out on their own...

@sneves
Copy link
Member

sneves commented Jun 22, 2016

cb0506c adds a small README that explains the available build options.

@grempe
Copy link
Author

grempe commented Jun 22, 2016

Thanks @sneves I think that tidies up this issue pretty well. Thanks for the help. Closing.

@grempe grempe closed this as completed Jun 22, 2016
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

3 participants