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

NodeJS 12.13.0 CentOS fail compile #30077

Closed
Delagen opened this issue Oct 23, 2019 · 18 comments
Closed

NodeJS 12.13.0 CentOS fail compile #30077

Delagen opened this issue Oct 23, 2019 · 18 comments
Labels
build Issues and PRs related to build files or the CI.

Comments

@Delagen
Copy link

Delagen commented Oct 23, 2019

  • Version: 12.13.0
  • Platform: CentOS 6 inside Docker
  • Subsystem:

../deps/v8/src/inspector/v8-runtime-agent-impl.cc: In member function 'virtual v8_inspector::protocol::Response v8_inspector::V8RuntimeAgentImpl::getIsolateId(v8_inspector::String16*)':
../deps/v8/src/inspector/v8-runtime-agent-impl.cc:626:38: error: expected ')' before 'PRIx64'
std::snprintf(buf, sizeof(buf), "%" PRIx64, m_inspector->isolateId());
~ ^~~~~~~
)
make[1]: *** [/tmp/tmp.Om2rLi9DCC/BUILD/node-v12.13.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/inspector/v8-runtime-agent-impl.o] Error 1
make: *** [node] Error 2

@bnoordhuis bnoordhuis added the build Issues and PRs related to build files or the CI. label Oct 23, 2019
@bnoordhuis
Copy link
Member

I'm going to guess that your system's header files don't define the PRIx64 macro that normally lives in inttypes.h.

Are you using devtoolset? Can you post the exact steps you use to set up your build environment and configure and build node?

@Delagen
Copy link
Author

Delagen commented Oct 23, 2019

I am using devtoolset-8 devtoolset-8-make devtoolset-8-gcc devtoolset-8-gcc-c++ inside docker container from centos:6.
Latest Node 10.x was compiled successfully

@bnoordhuis
Copy link
Member

I'm not 100% sure but I think we use devtoolset-6 or 7 to build on centos 6. Maybe give them a go.

@Delagen
Copy link
Author

Delagen commented Oct 23, 2019

docker run -it centos:6

yum update -y \
	&& yum install -y ca-certificates sudo yum-utils epel-release centos-release-scl-rh \
	&& yum-config-manager --enable rhel-server-rhscl-6-rpms \
	&& yum update -y

yum install -y \
		openssh-clients \
		devtoolset-7 devtoolset-7-make devtoolset-7-gcc devtoolset-7-gcc-c++ \
		python27 git \
		curl wget jq \
		bzip2 xz \
		pkgconfig automake autoconf \
		rpm-build rpm-sign rpmdevtools

. /opt/rh/devtoolset-7/enable
. /opt/rh/python27/enable

wget https://nodejs.org/dist/v12.13.0/node-v12.13.0.tar.gz
tar xf node-v12.13.0.tar.gz
cd node-v12.13.0

 ./configure --prefix=/usr/local
make

Result:

g++ -o /node-v12.13.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/inspector/v8-runtime-agent-impl.o ../deps/v8/src/inspector/v8-runtime-agent-impl.cc '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_X64' '-DV8_EMBEDDER_STRING="-node.12"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DENABLE_MINOR_MC' '-DV8_INTL_SUPPORT' '-DV8_USE_SNAPSHOT' '-DV8_CONCURRENT_MARKING' '-DV8_EMBEDDED_BUILTINS' '-DV8_USE_SIPHASH' '-DDISABLE_UNTRUSTED_CODE_MITIGATIONS' '-DV8_WIN64_UNWINDING_INFO' '-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_STATIC_IMPLEMENTATION=1' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/v8 -I../deps/v8/include -I/node-v12.13.0/out/Release/obj/gen/inspector-generated-output-root -I../deps/v8/third_party/inspector_protocol -I/node-v12.13.0/out/Release/obj/gen/torque-output-root -I/node-v12.13.0/out/Release/obj/gen/generate-bytecode-output-root -I../deps/icu-small/source/i18n -I../deps/icu-small/source/common  -pthread -Wno-unused-parameter -m64 -Wno-return-type -fno-strict-aliasing -m64 -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++1y -MMD -MF /node-v12.13.0/out/Release/.deps//node-v12.13.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/inspector/v8-runtime-agent-impl.o.d.raw   -c

../deps/v8/src/inspector/v8-runtime-agent-impl.cc: In member function 'virtual v8_inspector::protocol::Response v8_inspector::V8RuntimeAgentImpl::getIsolateId(v8_inspector::String16*)':
../deps/v8/src/inspector/v8-runtime-agent-impl.cc:626:39: error: expected ')' before 'PRIx64'
   std::snprintf(buf, sizeof(buf), "%" PRIx64, m_inspector->isolateId());
                                       ^~~~~~
make[1]: *** [tools/v8_gypfiles/v8_base_without_compiler.target.mk:627: /node-v12.13.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/inspector/v8-runtime-agent-impl.o] Error 1
rm a7d68dbc8fa1baa5f00537069835f94762111292.intermediate 466fb3915b04088edda5f262d4298bb1334a1bf8.intermediate
make: *** [Makefile:101: node] Error 2

@devnexen
Copy link
Contributor

devnexen commented Oct 23, 2019

I'm going to guess that your system's header files don't define the PRIx64 macro that normally lives in inttypes.h.

Are you using devtoolset? Can you post the exact steps you use to set up your build environment and configure and build node?

Seem they are in fact but might need to pass -D__STDC_FORMAT_MACROS flag, what do you think ?
In addition I needed to pass -lrt linker flag too and the build passes.

@bnoordhuis
Copy link
Member

gnulib has a note on it:

On some hosts that predate C++11, when using C++ one must define __STDC_FORMAT_MACROS to make visible the declarations of format macros such as PRIdMAX.

So I guess that means we need to define it for systems like OP's...

Someone want to send a PR? It should be added to cflags_cc in common.gypi.

@likema
Copy link

likema commented Nov 13, 2019

By GCC 6.5.0 on Ubuntu 12.04, it also has the same issue.

@Delagen
Copy link
Author

Delagen commented Jan 8, 2020

I think it not included in 12.14.1 release ((

@bnoordhuis
Copy link
Member

It was fixed in v13.6.0 but it'll take some time before it's eligible for v12.x LTS. Maybe in the next release. I'll close this out.

@Delagen
Copy link
Author

Delagen commented Jan 14, 2020

@bnoordhuis Even in 13.6.0 does not compile
Error

 undefined reference to `clock_gettime'
LINK(target) /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/cctest
4334 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o: In function `uv__hrtime':
4335 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/uv/src/unix/linux-core.c:489: undefined reference to `clock_gettime'
4336 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/uv/src/unix/linux-core.c:477: undefined reference to `clock_getres'
4337 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/uv/src/unix/linux-core.c:489: undefined reference to `clock_gettime'
4338 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/uv/src/unix/linux-core.c:477: undefined reference to `clock_getres'
4339 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o: In function `uv_uptime':
4340 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/uv/src/unix/linux-core.c:563: undefined reference to `clock_gettime'
4341 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/uv/src/unix/linux-core.c:565: undefined reference to `clock_gettime'
4342 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/diagnostics/perf-jit.o: In function `v8::internal::PerfJitLogger::WriteJitCodeLoadEntry(unsigned char const*, unsigned int, char const*, int) [clone .constprop.72]':
4343 perf-jit.cc:(.text._ZN2v88internal13PerfJitLogger21WriteJitCodeLoadEntryEPKhjPKci.constprop.72+0x32): undefined reference to `clock_gettime'
4344 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/diagnostics/perf-jit.o: In function `v8::internal::PerfJitLogger::LogWriteUnwindingInfo(v8::internal::Code) [clone .constprop.71]':
4345 perf-jit.cc:(.text._ZN2v88internal13PerfJitLogger21LogWriteUnwindingInfoENS0_4CodeE.constprop.71+0x28): undefined reference to `clock_gettime'
4346 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/diagnostics/perf-jit.o: In function `v8::internal::PerfJitLogger::LogRecordedBuffer(v8::internal::wasm::WasmCode const*, char const*, int)':
4347 perf-jit.cc:(.text._ZN2v88internal13PerfJitLogger17LogRecordedBufferEPKNS0_4wasm8WasmCodeEPKci+0x22f): undefined reference to `clock_gettime'
4348 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/diagnostics/perf-jit.o:perf-jit.cc:(.text._ZN2v88internal13PerfJitLogger17LogWriteDebugInfoENS0_4CodeENS0_18SharedFunctionInfoE.constprop.69+0xd6): more undefined references to `clock_gettime' follow
4349 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/uvwasi/deps/uvwasi/src/clocks.o: In function `uvwasi__clock_getres_process_cputime':
4350 clocks.c:(.text+0x126): undefined reference to `clock_getres'
4351 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/uvwasi/deps/uvwasi/src/clocks.o: In function `uvwasi__clock_getres_thread_cputime':
4352 clocks.c:(.text+0x166): undefined reference to `clock_gettime'
4353 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/cares/deps/cares/src/ares__timeval.o: In function `ares__tvnow':
4354 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/../deps/cares/src/ares__timeval.c:48: undefined reference to `clock_gettime'
4355 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/condition-variable.o: In function `v8::base::ConditionVariable::WaitFor(v8::base::Mutex*, v8::base::TimeDelta const&)':
4356 condition-variable.cc:(.text._ZN2v84base17ConditionVariable7WaitForEPNS0_5MutexERKNS0_9TimeDeltaE+0x20): undefined reference to `clock_gettime'
4357 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/time.o: In function `v8::base::TimeTicks::HighResolutionNow()':
4358 time.cc:(.text._ZN2v84base9TimeTicks17HighResolutionNowEv+0x12): undefined reference to `clock_gettime'
4359 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/time.o: In function `v8::base::TimeTicks::Now()':
4360 time.cc:(.text._ZN2v84base9TimeTicks3NowEv+0x12): undefined reference to `clock_gettime'
4361 /tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/time.o:time.cc:(.text._ZN2v84base9TimeTicks16IsHighResolutionEv+0x5a): more undefined references to `clock_gettime' follow
4362 collect2: error: ld returned 1 exit status
4363 make[1]: *** [/tmp/tmp.FC9mvdvjih/BUILD/node-v13.6.0/out/Release/cctest] Error 1
4364 make: *** [node] Error 2

@bnoordhuis
Copy link
Member

@Delagen That's an issue with your glibc being too old. You can probably work around it with this patch but it comes with zero warranties (as does node in general, of course.)

diff --git a/node.gypi b/node.gypi
index e6f5872cc7..4ed0207f0f 100644
--- a/node.gypi
+++ b/node.gypi
@@ -298,7 +298,7 @@
       'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
     }],
     [ 'OS=="linux"', {
-      'libraries!': [
+      'libraries': [
         '-lrt'
       ],
     }],

If it still doesn't work after that, you're on your own. :-)

@Delagen
Copy link
Author

Delagen commented Jan 15, 2020

@bnoordhuis Yes it works, but I fixed via ENV LDFLAGS: '-lrt'. Thanks

@ledbit
Copy link

ledbit commented Feb 7, 2020

@bnoordhuis is there a timeline to land this on 12.x? (it doesn't seem to be on 12.15.0)

@bnoordhuis
Copy link
Member

v12.15.0 was a security release, those don't contain regular bug fixes. It'll probably be in the next one.

@richardlau
Copy link
Member

Next one will be #31691.

@bnoordhuis
Copy link
Member

That one contains the fix.

@ledbit
Copy link

ledbit commented Feb 12, 2020

Confirming that 12.16.0 has the fix - as @Delagen mentioned you need to set LDFLAGS=-lrt env variable when compiling. Thanks!!

@atoomic
Copy link

atoomic commented Oct 2, 2020

Seems like you want to use both of these to compile nodejs v12 on CentOS 6

export LDFLAGS=-lrt
export CPPFLAGS=-D__STDC_FORMAT_MACROS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants