Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Fix crash on some linux environment (#229)
Browse files Browse the repository at this point in the history
* Fix crash caused by incorrect symbol pickup

* set non-lazy binding

* Update build matrix

* Update g++ version in comments
  • Loading branch information
fs-eire authored May 2, 2018
1 parent 0ebf6d5 commit b2c1398
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
52 changes: 27 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matrix:
# Disable the default build and use customized matrix only.
- compiler: default
include:
# Node 6.x Linux (Precise) G++5.4.1
# Node 6.x Linux (Precise) G++5.4.1
- os: linux
dist: precise
node_js: '6'
Expand All @@ -23,46 +23,31 @@ matrix:
- cmake
env:
- COMPILER_OVERRIDE="CXX=g++-5 CC=gcc-5"
# Node 6.x OS X (Yosemite) AppleClang 6.1
# Node 6.x OS X (Yosemite) AppleClang 6.1
- os: osx
node_js: '6'
osx_image: xcode6.4
# Node LTS (8.x) Linux (Trusty) G++6.3.0
# 2018-03-12 : There is a compability issue for the following platform/environment combination:
# - Ubuntu 14.04
# - Node 8.10.0 or later
# - Node 9.3.0 or later
# This issue causes a crash on Napa.js.
# Issue detail: https://github.com/nodejs/node/issues/17817
#
# Current available workaround:
# 1: Use Node 8.9.1 or 9.2.1
# 2: Use binaries (libnapa.so and napa-binding.node) that compiled in Ubuntu 16.04
#
# Since travis-CI does not support Ubuntu 16.04 yet, we locked Node version to 8.9.1
# for now.
# - fs-eire
# Node LTS (8.x) Linux (Trusty) G++6.4.0
- os: linux
dist: trusty
node_js: '8.9.1'
node_js: '8'
compiler: g++-6
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
- g++-6
env:
- COMPILER_OVERRIDE="CXX=g++-5 CC=gcc-5"
# Node LTS (8.x) OS X (El Capitan) AppleClang 7.3
- COMPILER_OVERRIDE="CXX=g++-6 CC=gcc-6"
# Node LTS (8.x) OS X (El Capitan) AppleClang 7.3
- os: osx
node_js: '8'
osx_image: xcode7.3
# Node Stable (9.x) Linux (Trusty) G++6.3.0
# 2017-12-18 : Locked node.js version to 9.2.1. See above.
# Node (9.x) Linux (Trusty) G++6.4.0
- os: linux
dist: trusty
node_js: '9.2.1'
node_js: '9'
compiler: g++-6
addons:
apt:
Expand All @@ -72,10 +57,27 @@ matrix:
- g++-6
env:
- COMPILER_OVERRIDE="CXX=g++-6 CC=gcc-6"
# Node Stable (9.x) macOS (Sierra) AppleClang 8.1
# Node (9.x) macOS (Sierra) AppleClang 8.1
- os: osx
node_js: '9'
osx_image: xcode8.3
# Node Current (10.x) Linux (Trusty) G++7.3.0
- os: linux
dist: trusty
node_js: '10'
compiler: g++-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- COMPILER_OVERRIDE="CXX=g++-7 CC=gcc-7"
# Node Current (10.x) macOS (High Sierra) AppleClang 9.1
- os: osx
node_js: '10'
osx_image: xcode9.3

before_install:
- |
Expand Down
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Set symbol visibility to hidden by default.
# Napa shared library shares a few classes with napa-binding.node with different compile definition,
# exposing the same symbols from both shared libraries may cause improper behaviors under gcc.
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN)
if (NOT WIN32 AND NOT APPLE)
# Set symbol visibility to hidden by default.
# Napa shared library shares a few classes with napa-binding.node with different compile definition,
# exposing the same symbols from both shared libraries may cause improper behaviors under gcc.
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN)

# Prevent symbol relocations internal to our wrapper library to be overwritten by the application.
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic -Wl,-Bsymbolic-functions")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-Bsymbolic -Wl,-Bsymbolic-functions")

# Mark object non-lazy runtime binding.
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,now")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,now")
endif ()

# Build napa shared library.
add_subdirectory(src)
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ environment:
# Windows Server 2016 Visual C++ Build Tools 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
nodejs_version: 9
# Windows Server 2016 Visual C++ Build Tools 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
nodejs_version: 10

platform:
- x64
Expand Down

0 comments on commit b2c1398

Please sign in to comment.