erlangpack / bcrypt

Erlang wrapper for OpenBSD's Blowfish password hashing code
https://hex.pm/packages/bcrypt
Other
16 stars 19 forks source link

Link failure on OTP 24 #28

Open whitelynx opened 2 years ago

whitelynx commented 2 years ago

I have Erlang 24.2 installed, and I'm getting linker errors when building bcrypt:

 make
/usr/bin/rebar3 compile
===> Verifying dependencies...
===> Fetching poolboy v1.5.2
===> Analyzing applications...
===> Compiling poolboy
make[1]: Entering directory '/home/whitelynx/Development/Other/bcrypt/c_src'
cc -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_DEFAULT_SOURCE -fPIC -I /usr/lib/erlang/erts-12.2/include/ -I /usr/lib/erlang/lib/erl_interface-5.1/include  -c -o bcrypt_port.o bcrypt_port.c
cc -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_DEFAULT_SOURCE -fPIC -I /usr/lib/erlang/erts-12.2/include/ -I /usr/lib/erlang/lib/erl_interface-5.1/include  -c -o blowfish.o blowfish.c
cc -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_DEFAULT_SOURCE -fPIC -I /usr/lib/erlang/erts-12.2/include/ -I /usr/lib/erlang/lib/erl_interface-5.1/include  -c -o bcrypt_nif.o bcrypt_nif.c
cc -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_DEFAULT_SOURCE -fPIC -I /usr/lib/erlang/erts-12.2/include/ -I /usr/lib/erlang/lib/erl_interface-5.1/include  -c -o bcrypt.o bcrypt.c
bcrypt.c: In function ‘encode_salt’:
bcrypt.c:137:38: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  137 |         snprintf(salt + 4, 4, "%2.2u$", logr);
      |                                      ^
bcrypt.c:137:9: note: ‘snprintf’ output between 4 and 5 bytes into a destination of size 4
  137 |         snprintf(salt + 4, 4, "%2.2u$", logr);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bcrypt.c: In function ‘ts_bcrypt’:
bcrypt.c:241:43: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  241 |         snprintf(encrypted + i, 4, "%2.2u$", logr);
      |                                           ^
bcrypt.c:241:9: note: ‘snprintf’ output between 4 and 5 bytes into a destination of size 4
  241 |         snprintf(encrypted + i, 4, "%2.2u$", logr);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_DEFAULT_SOURCE -fPIC -I /usr/lib/erlang/erts-12.2/include/ -I /usr/lib/erlang/lib/erl_interface-5.1/include  -c -o async_queue.o async_queue.c
cc ./bcrypt_port.o ./blowfish.o ./bcrypt_nif.o ./bcrypt.o ./async_queue.o  -shared -L /usr/lib/erlang/lib/erl_interface-5.1/lib -lei -lpthread -o ./../priv/bcrypt_nif.so
cc -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_DEFAULT_SOURCE -fPIC -I /usr/lib/erlang/erts-12.2/include/ -I /usr/lib/erlang/lib/erl_interface-5.1/include bcrypt_port.o bcrypt.o blowfish.o  -L /usr/lib/erlang/lib/erl_interface-5.1/lib -lei -lpthread -o ../priv/bcrypt
/usr/bin/ld: bcrypt_port.o: in function `process_reply':
bcrypt_port.c:(.text+0x5a): undefined reference to `ei_x_new_with_version'
/usr/bin/ld: bcrypt_port.c:(.text+0x6f): undefined reference to `ei_x_encode_tuple_header'
/usr/bin/ld: bcrypt_port.c:(.text+0x82): undefined reference to `ei_x_encode_long'
/usr/bin/ld: bcrypt_port.c:(.text+0x9f): undefined reference to `ei_x_encode_binary'
/usr/bin/ld: bcrypt_port.c:(.text+0x164): undefined reference to `ei_x_free'
/usr/bin/ld: bcrypt_port.o: in function `process_error_reply':
bcrypt_port.c:(.text+0x1ea): undefined reference to `ei_x_new_with_version'
/usr/bin/ld: bcrypt_port.c:(.text+0x1ff): undefined reference to `ei_x_encode_tuple_header'
/usr/bin/ld: bcrypt_port.c:(.text+0x212): undefined reference to `ei_x_encode_long'
/usr/bin/ld: bcrypt_port.c:(.text+0x225): undefined reference to `ei_x_encode_atom'
/usr/bin/ld: bcrypt_port.c:(.text+0x2f4): undefined reference to `ei_x_free'
/usr/bin/ld: bcrypt_port.o: in function `loop':
bcrypt_port.c:(.text+0x482): undefined reference to `ei_decode_version'
/usr/bin/ld: bcrypt_port.c:(.text+0x49d): undefined reference to `ei_decode_tuple_header'
/usr/bin/ld: bcrypt_port.c:(.text+0x4c0): undefined reference to `ei_decode_long'
/usr/bin/ld: bcrypt_port.c:(.text+0x4d6): undefined reference to `ei_decode_tuple_header'
/usr/bin/ld: bcrypt_port.c:(.text+0x501): undefined reference to `ei_get_type'
/usr/bin/ld: bcrypt_port.c:(.text+0x538): undefined reference to `ei_decode_binary'
/usr/bin/ld: bcrypt_port.c:(.text+0x55a): undefined reference to `ei_decode_long'
/usr/bin/ld: bcrypt_port.c:(.text+0x5a9): undefined reference to `ei_get_type'
/usr/bin/ld: bcrypt_port.c:(.text+0x5db): undefined reference to `ei_decode_binary'
/usr/bin/ld: bcrypt_port.o: in function `main':
bcrypt_port.c:(.text.startup+0x5): undefined reference to `ei_init'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:70: ../priv/bcrypt] Error 1
make[1]: Leaving directory '/home/whitelynx/Development/Other/bcrypt/c_src'
===> Hook for compile failed!

make: *** [Makefile:9: compile] Error 1
whitelynx commented 2 years ago

Found an issue that mentions some of these errors: https://github.com/alloverse/alloplace/issues/9#issuecomment-473797664

It looks like it may have to do with linker flags ordering. I'll try messing with those and see if I can get it building.

mworrell commented 2 years ago

We do run tests on OTP24, which seem to be fine.

What OS do you use?

whitelynx commented 2 years ago

I'm on Manjaro Linux. Using the official package for community/erlang 24.2-1.