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

[Bug] nodejs on FreeBSD may need to be patched #900

Open
PeterDaveHello opened this Issue Nov 9, 2015 · 9 comments

Comments

Projects
None yet
2 participants
@PeterDaveHello
Contributor

PeterDaveHello commented Nov 9, 2015

This may be a hard work, I hope not.

FreeBSD version via uname -a:

FreeBSD vm1 10.1-RELEASE-p19 FreeBSD 10.1-RELEASE-p19 #0: Sat Aug 22 03:55:09 UTC 2015 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64

nvm version:

$ git -C ~/.nvm status
HEAD detached at v0.29.0
nothing to commit, working directory clean

I found that I cannot do $ nvm install 0.12 on FreeBSD 10.1 amd64 with success, and the error messages came from compiler, both clang LLVM or gcc will have the same problem, and this is not nvm's problem but nvm looks to support FreeBSD in the codes:

https://github.com/creationix/nvm/blob/master/nvm.sh#L936

nvm_get_os() {
  local NVM_UNAME
  NVM_UNAME="$(uname -a)"
  local NVM_OS
  case "$NVM_UNAME" in
    Linux\ *) NVM_OS=linux ;;
    Darwin\ *) NVM_OS=darwin ;;
    SunOS\ *) NVM_OS=sunos ;;
    FreeBSD\ *) NVM_OS=freebsd ;;
  esac
  echo "$NVM_OS"
}

https://github.com/creationix/nvm/blob/master/nvm.sh#L1230-L1233

  if [ "_$NVM_OS" = "_freebsd" ]; then
    make='gmake'
    MAKE_CXX="CXX=c++"
  fi

So I think we should do something to work around.

The error message:

gmake -C out BUILDTYPE=Release V=1
gmake[1]: Entering directory '/net/gcs/104/0456096/.nvm/src/node-v0.12.7/out'
gmake[1]: Warning: File '../deps/v8/src/base/platform/platform-freebsd.cc' has modification time 34 s in the future
  c++ '-DV8_TARGET_ARCH_X64' '-DENABLE_DISASSEMBLER' -I../deps/v8  -pthread -Wall -Wextra -Wno-unused-parameter -m64 -fno-strict-aliasing -I/usr/local/include -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -MMD -MF /net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/.deps//net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-freebsd.o.d.raw  -c -o /net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-freebsd.o ../deps/v8/src/base/platform/platform-freebsd.cc
  c++ '-DV8_TARGET_ARCH_X64' '-DENABLE_DISASSEMBLER' -I../deps/v8  -pthread -Wall -Wextra -Wno-unused-parameter -m64 -fno-strict-aliasing -I/usr/local/include -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -MMD -MF /net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/.deps//net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-posix.o.d.raw  -c -o /net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-posix.o ../deps/v8/src/base/platform/platform-posix.cc
../deps/v8/src/base/platform/platform-posix.cc:330:10: error: static_cast from 'pthread_t' (aka 'pthread *') to 'int' is not allowed
  return static_cast<int>(pthread_self());
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../deps/v8/src/base/platform/platform-freebsd.cc:159:11: error: member reference base type 'int' is not a structure or union
    result.push_back(SharedLibraryAddress(start_of_path, start, end));
    ~~~~~~^~~~~~~~~~
1 error generated.
deps/v8/tools/gyp/v8_libbase.target.mk:100: recipe for target '/net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-posix.o' failed
gmake[1]: *** [/net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-posix.o] Error 1
1 errorgmake[1]: *** Waiting for unfinished jobs....
 generated.
deps/v8/tools/gyp/v8_libbase.target.mk:100: recipe for target '/net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-freebsd.o' failed
gmake[1]: *** [/net/gcs/104/0456096/.nvm/src/node-v0.12.7/out/Release/obj.target/v8_libbase/deps/v8/src/base/platform/platform-freebsd.o] Error 1
gmake[1]: Leaving directory '/net/gcs/104/0456096/.nvm/src/node-v0.12.7/out'
Makefile:45: recipe for target 'node' failed
gmake: *** [node] Error 2

I remember that I installed it from ports and pkg with success before, so I copied the patch from FreeBSD's ports system
(https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc)

/usr/ports/www/node012/files/patch-deps_v8_src_base_platform_platform-freebsd.cc
/usr/ports/www/node012/files/patch-deps_v8_src_base_platform_platform-posix.cc

Apply the patches:

 $ patch < patch-deps_v8_src_base_platform_platform-freebsd.cc
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- deps/v8/src/base/platform/platform-freebsd.cc.orig 2015-03-31 22:13:01 UTC
|+++ deps/v8/src/base/platform/platform-freebsd.cc
--------------------------
Patching file deps/v8/src/base/platform/platform-freebsd.cc using Plan A...
Hunk #1 succeeded at 131.
Hunk #2 succeeded at 182.
Hunk #3 succeeded at 260.
Hunk #4 succeeded at 288.
done

$ patch < patch-deps_v8_src_base_platform_platform-posix.cc
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- deps/v8/src/base/platform/platform-posix.cc.orig   2015-03-31 22:13:01 UTC
|+++ deps/v8/src/base/platform/platform-posix.cc
--------------------------
Patching file deps/v8/src/base/platform/platform-posix.cc using Plan A...
Hunk #1 succeeded at 327 (offset -1 lines).
done

After the patches applied, there is no problem anymore!

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Nov 9, 2015

Collaborator

That definitely seems way out of scope for nvm - using a slightly different make binary is one thing, but applying patches isn't something I'm comfortable with. Perhaps you could convince node itself to fix it?

Collaborator

ljharb commented Nov 9, 2015

That definitely seems way out of scope for nvm - using a slightly different make binary is one thing, but applying patches isn't something I'm comfortable with. Perhaps you could convince node itself to fix it?

@PeterDaveHello

This comment has been minimized.

Show comment
Hide comment
@PeterDaveHello

PeterDaveHello Nov 9, 2015

Contributor

I sent a issue ticket here nodejs/node#3716 hope we can find a good way to figure it out!

Contributor

PeterDaveHello commented Nov 9, 2015

I sent a issue ticket here nodejs/node#3716 hope we can find a good way to figure it out!

@PeterDaveHello

This comment has been minimized.

Show comment
Hide comment
@PeterDaveHello

PeterDaveHello Nov 9, 2015

Contributor

BTW, clang LLVM is really fast! 👍

Compilation time spent by clang LLVM:

real 1m49.474s
user 14m51.253s
sys 2m0.750s

Compilation time spent by clang GCC:

real 2m23.481s
user 20m24.823s
sys 2m54.503s

Contributor

PeterDaveHello commented Nov 9, 2015

BTW, clang LLVM is really fast! 👍

Compilation time spent by clang LLVM:

real 1m49.474s
user 14m51.253s
sys 2m0.750s

Compilation time spent by clang GCC:

real 2m23.481s
user 20m24.823s
sys 2m54.503s

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Nov 9, 2015

Collaborator

@PeterDaveHello as a separate issue/PR, could you look into using the faster approach on all compilations, via feature detection? If we can speed up source compilation, "build from source" tests might not time out, and then I could support building everything from source :-D

Collaborator

ljharb commented Nov 9, 2015

@PeterDaveHello as a separate issue/PR, could you look into using the faster approach on all compilations, via feature detection? If we can speed up source compilation, "build from source" tests might not time out, and then I could support building everything from source :-D

@PeterDaveHello

This comment has been minimized.

Show comment
Hide comment
@PeterDaveHello

PeterDaveHello Nov 9, 2015

Contributor

@ljharb what do you mean all compilations actually? All versions of nodejs? Maybe we can open another issue ticket to discuss with that, I'll be happy to help in my capacity.

Contributor

PeterDaveHello commented Nov 9, 2015

@ljharb what do you mean all compilations actually? All versions of nodejs? Maybe we can open another issue ticket to discuss with that, I'll be happy to help in my capacity.

@PeterDaveHello

This comment has been minimized.

Show comment
Hide comment
@PeterDaveHello

PeterDaveHello Nov 9, 2015

Contributor

BTW,
nvm install 0.10 can build and install node with success:

 ~/.nvm/src/node-v0.10.40 $ ./out/Release/node --version
v0.10.40

nvm install 0.8, nvm install 0.6 can build node with success but failed on installing npm:

Installing npm...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    218      0 --:--:-- --:--:-- --:--:--   218
100  6263  100  6263    0     0   1931      0  0:00:03  0:00:03 --:--:--  3532
tar=/usr/bin/tar
version:
bsdtar 3.1.2 - libarchive 3.1.2
fetching: {
curl: (3) [globbing] unmatched brace in column 1
cd: /tmp/npm.56710/*: No such file or directory
It failed

and v0.11 has similar problem as v0.12

Contributor

PeterDaveHello commented Nov 9, 2015

BTW,
nvm install 0.10 can build and install node with success:

 ~/.nvm/src/node-v0.10.40 $ ./out/Release/node --version
v0.10.40

nvm install 0.8, nvm install 0.6 can build node with success but failed on installing npm:

Installing npm...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    218      0 --:--:-- --:--:-- --:--:--   218
100  6263  100  6263    0     0   1931      0  0:00:03  0:00:03 --:--:--  3532
tar=/usr/bin/tar
version:
bsdtar 3.1.2 - libarchive 3.1.2
fetching: {
curl: (3) [globbing] unmatched brace in column 1
cd: /tmp/npm.56710/*: No such file or directory
It failed

and v0.11 has similar problem as v0.12

@PeterDaveHello PeterDaveHello changed the title from [Bug] nodejs on FreeBSD(10.1) need to be patched to [Bug] nodejs on FreeBSD need to be patched Nov 9, 2015

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Nov 9, 2015

Collaborator

@PeterDaveHello yes - if clang LLVM is that much faster than gcc, then we should build with that whenever possible on every platform for every version

Collaborator

ljharb commented Nov 9, 2015

@PeterDaveHello yes - if clang LLVM is that much faster than gcc, then we should build with that whenever possible on every platform for every version

@PeterDaveHello

This comment has been minimized.

Show comment
Hide comment
@PeterDaveHello

PeterDaveHello Nov 9, 2015

Contributor

Okay, #902

Contributor

PeterDaveHello commented Nov 9, 2015

Okay, #902

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Sep 3, 2016

Collaborator

Related to #130 and #1207.

Collaborator

ljharb commented Sep 3, 2016

Related to #130 and #1207.

@PeterDaveHello PeterDaveHello changed the title from [Bug] nodejs on FreeBSD need to be patched to [Bug] nodejs on FreeBSD may need to be patched Mar 25, 2017

PeterDaveHello added a commit to PeterDaveHello/nvm that referenced this issue Mar 28, 2017

ljharb added a commit to PeterDaveHello/nvm that referenced this issue Mar 30, 2017

edwmurph pushed a commit to edwmurph/nvm that referenced this issue Apr 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment