Revert "build,test: add duplicate symbol test"

This reverts commit 2761afbf73.

Building with `-fvisibility=hidden` breaks some of Node's add-on tests
and therefore likely also affects third-party add-ons. This change was
landed in a patch release so I'm opting to revert it until the next
major release.

PR-URL: https://github.com/nodejs/node-gyp/pull/1828
Refs: https://github.com/nodejs/node/pull/28647#issuecomment-511715968
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
Ben Noordhuis 2019-07-16 10:22:38 +02:00 committed by Rod Vagg
parent 66ad305775
commit 0878db3b81
No known key found for this signature in database
GPG key ID: C273792F7D83545D
8 changed files with 0 additions and 119 deletions

View file

@ -1,10 +0,0 @@
#include <nan.h>
#include "common.h"
void Init(v8::Local<v8::Object> exports) {
Nan::Set(exports, Nan::New("pointerCheck").ToLocalChecked(),
Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(Something::PointerCheck)).ToLocalChecked());
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Init)

View file

@ -1,19 +0,0 @@
{
"target_defaults": {
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"sources": [
"binding.cc",
"extra.cc"
]
},
"targets": [
{
"target_name": "binding1",
},
{
"target_name": "binding2",
}
]
}

View file

@ -1,37 +0,0 @@
#ifndef DUPLICATE_SYMBOLS_COMMON_H_
#define DUPLICATE_SYMBOLS_COMMON_H_
#include <nan.h>
class Something {
public:
static void PointerCheck(const Nan::FunctionCallbackInfo<v8::Value>& info);
};
// Removing the inline keyword below will result in the addon failing to link
// on OSX because of a duplicate symbol.
inline void
Something::PointerCheck(const Nan::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Value> v8result;
if (info.Length() > 0) {
// If an argument was passed in, it is a pointer to the `PointerCheck`
// method from the other addon. So, we compare it to the value of the
// pointer to the `PointerCheck` method in this addon, and return
// `"equal"` if they are equal, and `"not equal"` otherwise".
const char* result =
(reinterpret_cast<void*>(Something::PointerCheck) ==
info[0].As<v8::External>()->Value()) ?
"equal" : "not equal";
v8result = Nan::New(result).ToLocalChecked();
} else {
// If no argument was passed in, we wrap the pointer to the `PointerCheck`
// method in this addon into a `v8::External` and pass it into JavaScript.
v8result = Nan::New<v8::External>(
reinterpret_cast<void*>(Something::PointerCheck));
}
info.GetReturnValue().Set(v8result);
}
#endif // DUPLICATE_SYMBOLS_COMMON_H_

View file

@ -1,6 +0,0 @@
#include "common.h"
// It is important that common.h be included from two different translation
// units, because doing so can create duplicate symbols in some instances. If
// it does so and fails to build because of it, that is considered a test
// failure.

View file

@ -1,5 +0,0 @@
'use strict'
module.exports = {
pointerCheck1: require('bindings')('binding1').pointerCheck,
pointerCheck2: require('bindings')('binding2').pointerCheck
};

View file

@ -1,14 +0,0 @@
{
"name": "duplicate_symbols",
"version": "0.0.0",
"description": "Duplicate Symbols Test",
"main": "index.js",
"private": true,
"dependencies": {
"bindings": "~1.2.1",
"nan": "^2.14.0"
},
"scripts": {
"test": "node index.js"
}
}

View file

@ -18,15 +18,6 @@ function runHello (hostProcess) {
return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString()
}
function runDuplicateBindings () {
const hostProcess = process.execPath
var testCode =
'console.log((function(bindings) {' +
'return bindings.pointerCheck1(bindings.pointerCheck2());' +
"})(require('duplicate_symbols')))"
return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString()
}
function getEncoding () {
var code = 'import locale;print(locale.getdefaultlocale()[1])'
return execFileSync('python', [ '-c', code ]).toString().trim()
@ -60,21 +51,6 @@ 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)