Node.bcrypt.js: bcrypt musl u_int8_t

Created on 21 Feb 2020  路  4Comments  路  Source: kelektiv/node.bcrypt.js

FROM node:12.14-alpine AS deps

RUN apk add --virtual deps \
  python \
  build-base

[鈥

RUN yarn install --production
RUN npm_config_build_from_source=true yarn rebuild bcrypt

[鈥

What went wrong

Compilation error due to types u_int32_t and u_int8_t not being defined.

What was expected

Successful compilation. Either -DBSD_SOURCE or -DGNU_SOURCE being passed to the preprocessor or portable types, not hidden behind compatibility flags, being used.

Host information

On the bare metal, my workstation is running Windows 10, but the compilation takes place inside an Alpine Linux Docker container against musl and Node 12.14.1.

> uname -a
MSYS_NT-10.0-17134 Lappi 3.0.7-338.x86_64 2019-07-03 15:16 UTC x86_64 Msys

compilation log

gyp info using [email protected] | linux | x64 gyp info spawn make gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] make: Entering directory '/app/node_modules/bcrypt/build' CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o AR(target) Release/obj.target/../node-addon-api/src/nothing.a COPY Release/nothing.a CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o In file included from ../src/bcrypt_node.cc:8: ../src/node_blf.h:84:2: error: 'u_int32_t' does not name a type; did you mean 'uint32_t'? 84 | u_int32_t S[4][256]; /* S-Boxes */ | ^~~~~~~~~ | uint32_t ../src/node_blf.h:85:2: error: 'u_int32_t' does not name a type; did you mean 'uint32_t'? 85 | u_int32_t P[BLF_N + 2]; /* Subkeys */ | ^~~~~~~~~ | uint32_t ../src/node_blf.h:94:35: error: 'u_int32_t' has not been declared 94 | void Blowfish_encipher(blf_ctx *, u_int32_t *, u_int32_t *); | ^~~~~~~~~ ../src/node_blf.h:94:48: error: 'u_int32_t' has not been declared 94 | void Blowfish_encipher(blf_ctx *, u_int32_t *, u_int32_t *); | ^~~~~~~~~ ../src/node_blf.h:95:35: error: 'u_int32_t' has not been declared 95 | void Blowfish_decipher(blf_ctx *, u_int32_t *, u_int32_t *); | ^~~~~~~~~ ../src/node_blf.h:95:48: error: 'u_int32_t' has not been declared 95 | void Blowfish_decipher(blf_ctx *, u_int32_t *, u_int32_t *); | ^~~~~~~~~ ../src/node_blf.h:97:45: error: 'u_int8_t' does not name a type; did you mean 'uint8_t'? 97 | void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t); | ^~~~~~~~ | uint8_t ../src/node_blf.h:97:57: error: 'u_int16_t' has not been declared 97 | void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:99:19: error: 'u_int8_t' does not name a type; did you mean 'uint8_t'? 99 | (blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t); | ^~~~~~~~ | uint8_t ../src/node_blf.h:99:31: error: 'u_int16_t' has not been declared 99 | (blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:99:48: error: 'u_int8_t' does not name a type; did you mean 'uint8_t'? 99 | (blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t); | ^~~~~~~~ | uint8_t ../src/node_blf.h:99:60: error: 'u_int16_t' has not been declared 99 | (blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:103:31: error: 'u_int8_t' does not name a type; did you mean 'uint8_t'? 103 | void blf_key(blf_ctx *, const u_int8_t *, u_int16_t); | ^~~~~~~~ | uint8_t ../src/node_blf.h:103:43: error: 'u_int16_t' has not been declared 103 | void blf_key(blf_ctx *, const u_int8_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:104:25: error: 'u_int32_t' has not been declared 104 | void blf_enc(blf_ctx *, u_int32_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:104:38: error: 'u_int16_t' has not been declared 104 | void blf_enc(blf_ctx *, u_int32_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:105:25: error: 'u_int32_t' has not been declared 105 | void blf_dec(blf_ctx *, u_int32_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:105:38: error: 'u_int16_t' has not been declared 105 | void blf_dec(blf_ctx *, u_int32_t *, u_int16_t); | ^~~~~~~~~ ../src/node_blf.h:107:33: error: 'u_int8_t' has not been declared 107 | void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t); | ^~~~~~~~ ../src/node_blf.h:107:45: error: 'u_int32_t' has not been declared 107 | void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t); | ^~~~~~~~~ ../src/node_blf.h:108:33: error: 'u_int8_t' has not been declared 108 | void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t); | ^~~~~~~~ ../src/node_blf.h:108:45: error: 'u_int32_t' has not been declared 108 | void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t); | ^~~~~~~~~ ../src/node_blf.h:110:33: error: 'u_int8_t' has not been declared 110 | void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); | ^~~~~~~~ ../src/node_blf.h:110:45: error: 'u_int8_t' has not been declared 110 | void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); | ^~~~~~~~ ../src/node_blf.h:110:57: error: 'u_int32_t' has not been declared 110 | void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); | ^~~~~~~~~ ../src/node_blf.h:111:33: error: 'u_int8_t' has not been declared 111 | void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); | ^~~~~~~~ ../src/node_blf.h:111:45: error: 'u_int8_t' has not been declared 111 | void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); | ^~~~~~~~ ../src/node_blf.h:111:57: error: 'u_int32_t' has not been declared 111 | void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); | ^~~~~~~~~ ../src/node_blf.h:114:1: error: 'u_int32_t' does not name a type; did you mean 'uint32_t'? 114 | u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t , u_int16_t *); | ^~~~~~~~~ | uint32_t ../src/node_blf.h:117:27: error: 'u_int8_t' has not been declared 117 | void bcrypt_gensalt(char, u_int8_t, u_int8_t*, char *); | ^~~~~~~~ ../src/node_blf.h:117:37: error: 'u_int8_t' has not been declared 117 | void bcrypt_gensalt(char, u_int8_t, u_int8_t*, char *); | ^~~~~~~~ ../src/node_blf.h:119:26: error: 'u_int8_t' has not been declared 119 | void encode_salt(char *, u_int8_t *, char, u_int16_t, u_int8_t); | ^~~~~~~~ ../src/node_blf.h:119:44: error: 'u_int16_t' has not been declared 119 | void encode_salt(char *, u_int8_t *, char, u_int16_t, u_int8_t); | ^~~~~~~~~ ../src/node_blf.h:119:55: error: 'u_int8_t' has not been declared 119 | void encode_salt(char *, u_int8_t *, char, u_int16_t, u_int8_t); | ^~~~~~~~ ../src/node_blf.h:120:1: error: 'u_int32_t' does not name a type; did you mean 'uint32_t'? 120 | u_int32_t bcrypt_get_rounds(const char *); | ^~~~~~~~~ | uint32_t ../src/bcrypt_node.cc: In member function 'virtual void {anonymous}::SaltAsyncWorker::Execute()': ../src/bcrypt_node.cc:79:52: error: 'u_int8_t' was not declared in this scope; did you mean 'uint8_t'? 79 | bcrypt_gensalt(minor_ver, rounds, (u_int8_t *)&seed[0], salt); | ^~~~~~~~ | uint8_t ../src/bcrypt_node.cc:79:62: error: expected primary-expression before ')' token 79 | bcrypt_gensalt(minor_ver, rounds, (u_int8_t *)&seed[0], salt); | ^ ../src/bcrypt_node.cc: In function 'Napi::Value {anonymous}::GenerateSaltSync(const Napi::CallbackInfo&)': ../src/bcrypt_node.cc:129:22: error: 'u_int8_t' was not declared in this scope; did you mean 'uint8_t'? 129 | Napi::Buffer<u_int8_t> buffer = info[2].As<Napi::Buffer<u_int8_t>>(); | ^~~~~~~~ | uint8_t ../src/bcrypt_node.cc:129:30: error: template argument 1 is invalid 129 | Napi::Buffer<u_int8_t> buffer = info[2].As<Napi::Buffer<u_int8_t>>(); | ^ ../src/bcrypt_node.cc:129:76: error: no matching function for call to 'Napi::Value::As<<expression error> >() const' 129 | Napi::Buffer<u_int8_t> buffer = info[2].As<Napi::Buffer<u_int8_t>>(); | ^ In file included from /app/node_modules/node-addon-api/napi.h:2169, from ../src/bcrypt_node.cc:1: /app/node_modules/node-addon-api/napi-inl.h:495:10: note: candidate: 'template<class T> T Napi::Value::As() const' 495 | inline T Value::As() const { | ^~~~~ /app/node_modules/node-addon-api/napi-inl.h:495:10: note: template argument deduction/substitution failed: ../src/bcrypt_node.cc:129:76: error: template argument 1 is invalid 129 | Napi::Buffer<u_int8_t> buffer = info[2].As<Napi::Buffer<u_int8_t>>(); | ^ ../src/bcrypt_node.cc:130:19: error: 'seed' was not declared in this scope 130 | u_int8_t* seed = (u_int8_t*) buffer.Data(); | ^~~~ ../src/bcrypt_node.cc:130:36: error: expected primary-expression before ')' token 130 | u_int8_t* seed = (u_int8_t*) buffer.Data(); | ^ ../src/bcrypt_node.cc:129:32: warning: unused variable 'buffer' [-Wunused-variable] 129 | Napi::Buffer<u_int8_t> buffer = info[2].As<Napi::Buffer<u_int8_t>>(); | ^~~~~~ ../src/bcrypt_node.cc: In function 'Napi::Value {anonymous}::GetRounds(const Napi::CallbackInfo&)': ../src/bcrypt_node.cc:259:9: error: 'u_int32_t' was not declared in this scope; did you mean 'uint32_t'? 259 | u_int32_t rounds; | ^~~~~~~~~ | uint32_t ../src/bcrypt_node.cc:260:15: error: 'rounds' was not declared in this scope 260 | if (!(rounds = bcrypt_get_rounds(hash.c_str()))) { | ^~~~~~ ../src/bcrypt_node.cc:260:24: error: 'bcrypt_get_rounds' was not declared in this scope 260 | if (!(rounds = bcrypt_get_rounds(hash.c_str()))) { | ^~~~~~~~~~~~~~~~~ ../src/bcrypt_node.cc:263:39: error: 'rounds' was not declared in this scope 263 | return Napi::Number::New(env, rounds); | ^~~~~~ make: *** [bcrypt_lib.target.mk:112: Release/obj.target/bcrypt_lib/src/bcrypt_node.o] Error 1 make: Leaving directory '/app/node_modules/bcrypt/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23) gyp ERR! stack at ChildProcess.emit (events.js:223:5) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) gyp ERR! System Linux 4.19.76-linuxkit gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/app/node_modules/bcrypt/lib/binding/napi-v3" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3" gyp ERR! cwd /app/node_modules/bcrypt gyp ERR! node -v v12.14.1 gyp ERR! node-gyp -v v5.0.5 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/app/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=5 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:223:5) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) node-pre-gyp ERR! System Linux 4.19.76-linuxkit node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /app/node_modules/bcrypt node-pre-gyp ERR! node -v v12.14.1 node-pre-gyp ERR! node-pre-gyp -v v0.14.0 node-pre-gyp ERR! not ok Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/app/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=5 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1) ERROR: Service 'typescript' failed to build: The command '/bin/sh -c yarn install --production' returned a non-zero code: 1

Most helpful comment

Publishing this weekend

All 4 comments

I believe this is fixed now since #783 was merged, but no release has been cut yet.

Publishing this weekend

We need 4.0.1 published on NPM as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

youngrrrr picture youngrrrr  路  5Comments

surendra172001 picture surendra172001  路  5Comments

megmut picture megmut  路  6Comments

olsnacky picture olsnacky  路  4Comments

amjedomar picture amjedomar  路  5Comments