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

Re-introduce duplicate symbol check #1891

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addon.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@

'conditions': [
[ 'OS=="mac"', {
'cflags': [
'-fvisibility=hidden'
],
'defines': [
'_DARWIN_USE_64_BIT_INODE=1'
],
'xcode_settings': {
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
'DYLIB_INSTALL_NAME_BASE': '@rpath'
},
}],
Expand Down
10 changes: 10 additions & 0 deletions test/node_modules/duplicate_symbols/binding.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions test/node_modules/duplicate_symbols/binding.gyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions test/node_modules/duplicate_symbols/common.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/node_modules/duplicate_symbols/extra.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/node_modules/duplicate_symbols/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/node_modules/duplicate_symbols/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions test/test-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ function getEncoding () {
return execFileSync('python', ['-c', code]).toString().trim()
}

function runDuplicateBindings () {
const hostProcess = process.execPath
const testCode =
'console.log((function(bindings) {' +
'return bindings.pointerCheck1(bindings.pointerCheck2());' +
"})(require('duplicate_symbols')))"
return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString()
}

function checkCharmapValid () {
var data
try {
Expand Down Expand Up @@ -51,6 +60,21 @@ test('build simple addon', function (t) {
proc.stderr.setEncoding('utf-8')
})

test('make sure addon symbols do not overlap', function (t) {
t.plan(3)

var addonPath = path.resolve(__dirname, 'node_modules', 'duplicate_symbols')
// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
t.strictEqual(err, null)
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
t.strictEqual(runDuplicateBindings().trim(), 'not equal')
})
})

test('build simple addon in path with non-ascii characters', function (t) {
t.plan(1)

Expand Down