test: rebuild nan tests with libc++ and libc++abi (#29281)
* test: re-enable nan test: typedarrays-test.js Fixes #28414. I've confirmed this fix wfm on Linux. Pushing into a PR to get CI to run it out on Win and Mac platforms too. * chore: clarify comment * test: fix NAN test string alignment * test: (wip) add ldflags, archive file for libc++ * test: (wip) add libc++ to CircleCI * test: (wip) add llvm flags * test: (wip) change ldflag syntax * test: (wip) build libc++abi as static * fix: correct ldflags * test: add ld env * fix: do not commit this * test: add lld from src to circleci * test: add lld link to ld * chore: preserve third_party * seems legit * sam swears this works kinda sort of sometimes' : * build: add gn visibility patch * chore: update patches * build: check for flatten_relative_to = false * build: upload zip files, add to release.js validation * debug: what the hell gn * build: add libcxx gni to lint ignore Linting the file adjusted the licenses array, which only contains one value, and causes the gn check to fail later * build: also use nan-spec-runner flags on Windows * build: add linked flags for win32 only * build: build libc++ as source on win * build: clean up patch, add -fPIC for IA32 * build: delete libcxx .a files from root * build: rename libc++.zip, clean up upload per platform * build: fix gni lint * ci: add libcxx gen to circleci config * build: correct libcxx-object syntax Co-authored-by: Samuel Attard <sam@electronjs.org> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: clavin <clavin@electronjs.org> Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sam@electronjs.org>
This commit is contained in:
parent
259bf8c4f7
commit
d03325541f
14 changed files with 497 additions and 8 deletions
48
script/gen-libc++-filenames.js
Normal file
48
script/gen-libc++-filenames.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const check = process.argv.includes('--check');
|
||||
|
||||
function findAllHeaders (basePath) {
|
||||
const allFiles = fs.readdirSync(basePath);
|
||||
const toReturn = [];
|
||||
for (const file of allFiles) {
|
||||
const absPath = path.resolve(basePath, file);
|
||||
if (fs.statSync(absPath).isDirectory()) {
|
||||
toReturn.push(...findAllHeaders(absPath));
|
||||
} else {
|
||||
toReturn.push(absPath);
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
for (const folder of ['libc++', 'libc++abi']) {
|
||||
const prettyName = folder.replace(/\+/g, 'x');
|
||||
|
||||
const libcxxIncludeDir = path.resolve(__dirname, '..', '..', 'buildtools', 'third_party', folder, 'trunk', 'include');
|
||||
const gclientPath = `buildtools/third_party/${folder}/trunk/include`;
|
||||
|
||||
const headers = findAllHeaders(libcxxIncludeDir).map(absPath => path.relative(path.resolve(__dirname, '../..', gclientPath), absPath));
|
||||
|
||||
const content = `${prettyName}_headers = [
|
||||
${headers.map(f => `"//${path.posix.join(gclientPath, f)}"`).join(',\n ')},
|
||||
]
|
||||
|
||||
${prettyName}_licenses = [ "//buildtools/third_party/${folder}/trunk/LICENSE.TXT" ]
|
||||
`;
|
||||
|
||||
const filenamesPath = path.resolve(__dirname, '..', `filenames.${prettyName}.gni`);
|
||||
|
||||
if (check) {
|
||||
const currentContent = fs.readFileSync(filenamesPath, 'utf8');
|
||||
if (currentContent !== content) {
|
||||
console.log('currentContent: ', currentContent);
|
||||
console.log('content: ', content);
|
||||
throw new Error(`${prettyName} filenames need to be regenerated, latest generation does not match current file. Please run node gen-libc++-filenames.js`);
|
||||
}
|
||||
} else {
|
||||
console.log(filenamesPath);
|
||||
fs.writeFileSync(filenamesPath, content);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,43 @@ async function main () {
|
|||
npm_config_arch: process.env.NPM_CONFIG_ARCH,
|
||||
npm_config_yes: 'true'
|
||||
});
|
||||
const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--directory', 'test', '-j', 'max'], {
|
||||
|
||||
const clangDir = path.resolve(BASE, 'third_party', 'llvm-build', 'Release+Asserts', 'bin');
|
||||
const cc = path.resolve(clangDir, 'clang');
|
||||
const cxx = path.resolve(clangDir, 'clang++');
|
||||
const ld = path.resolve(clangDir, 'lld');
|
||||
|
||||
// TODO(ckerr) this is cribbed from read obj/electron/electron_app.ninja.
|
||||
// Maybe it would be better to have this script literally open up that
|
||||
// file and pull cflags_cc from it instead of using bespoke code here?
|
||||
// I think it's unlikely to work; but if it does, it would be more futureproof
|
||||
const cxxflags = [
|
||||
'-std=c++14',
|
||||
'-nostdinc++',
|
||||
'-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS', // needed by next line
|
||||
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++', 'trunk', 'include')}"`,
|
||||
`-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++abi', 'trunk', 'include')}"`,
|
||||
'-fPIC'
|
||||
].join(' ');
|
||||
|
||||
const ldflags = [
|
||||
'-stdlib=libc++',
|
||||
'-fuse-ld=lld',
|
||||
`-L"${path.resolve(BASE, 'out', `${utils.getOutDir({ shouldLog: true })}`, 'obj', 'buildtools', 'third_party', 'libc++abi')}"`,
|
||||
`-L"${path.resolve(BASE, 'out', `${utils.getOutDir({ shouldLog: true })}`, 'obj', 'buildtools', 'third_party', 'libc++')}"`,
|
||||
'-lc++abi'
|
||||
].join(' ');
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
env.CC = cc;
|
||||
env.CFLAGS = cxxflags;
|
||||
env.CXX = cxx;
|
||||
env.LD = ld;
|
||||
env.CXXFLAGS = cxxflags;
|
||||
env.LDFLAGS = ldflags;
|
||||
}
|
||||
|
||||
const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--verbose', '--directory', 'test', '-j', 'max'], {
|
||||
env,
|
||||
cwd: NAN_DIR,
|
||||
stdio: 'inherit'
|
||||
|
@ -48,9 +84,7 @@ async function main () {
|
|||
const onlyTests = args.only && args.only.split(',');
|
||||
|
||||
const DISABLED_TESTS = [
|
||||
'nannew-test.js',
|
||||
'setcallhandler-test.js', // TODO(jkleinsc) renable once https://github.com/electron/electron/pull/29028 lands
|
||||
'typedarrays-test.js' // TODO(nornagon): https://github.com/electron/electron/issues/28414
|
||||
'nannew-test.js'
|
||||
];
|
||||
const testsToRun = fs.readdirSync(path.resolve(NAN_DIR, 'test', 'js'))
|
||||
.filter(test => !DISABLED_TESTS.includes(test))
|
||||
|
|
|
@ -139,6 +139,12 @@ function assetsForVersion (version, validatingRelease) {
|
|||
'electron-api.json',
|
||||
'electron.d.ts',
|
||||
'hunspell_dictionaries.zip',
|
||||
'libcxx_headers.zip',
|
||||
'libcxxabi_headers.zip',
|
||||
`libcxx-objects-${version}-linux-arm64.zip`,
|
||||
`libcxx-objects-${version}-linux-armv7l.zip`,
|
||||
`libcxx-objects-${version}-linux-ia32.zip`,
|
||||
`libcxx-objects-${version}-linux-x64.zip`,
|
||||
`ffmpeg-${version}-darwin-x64.zip`,
|
||||
`ffmpeg-${version}-darwin-arm64.zip`,
|
||||
`ffmpeg-${version}-linux-arm64.zip`,
|
||||
|
|
|
@ -37,6 +37,8 @@ PDB_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'pdb')
|
|||
DEBUG_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'debug')
|
||||
TOOLCHAIN_PROFILE_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION,
|
||||
'toolchain-profile')
|
||||
CXX_OBJECTS_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION,
|
||||
'libcxx_objects')
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -95,6 +97,20 @@ def main():
|
|||
shutil.copy2(os.path.join(OUT_DIR, 'debug.zip'), debug_zip)
|
||||
upload_electron(release, debug_zip, args)
|
||||
|
||||
# Upload libcxx_objects.zip for linux only
|
||||
libcxx_objects = get_zip_name('libcxx-objects', ELECTRON_VERSION)
|
||||
libcxx_objects_zip = os.path.join(OUT_DIR, libcxx_objects)
|
||||
shutil.copy2(os.path.join(OUT_DIR, 'libcxx_objects.zip'), libcxx_objects_zip)
|
||||
upload_electron(release, libcxx_objects_zip, args)
|
||||
|
||||
# Upload headers.zip and abi_headers.zip as non-platform specific
|
||||
if get_target_arch() == "x64":
|
||||
cxx_headers_zip = os.path.join(OUT_DIR, 'libcxx_headers.zip')
|
||||
upload_electron(release, cxx_headers_zip, args)
|
||||
|
||||
abi_headers_zip = os.path.join(OUT_DIR, 'libcxxabi_headers.zip')
|
||||
upload_electron(release, abi_headers_zip, args)
|
||||
|
||||
# Upload free version of ffmpeg.
|
||||
ffmpeg = get_zip_name('ffmpeg', ELECTRON_VERSION)
|
||||
ffmpeg_zip = os.path.join(OUT_DIR, ffmpeg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue