Skip to content

Commit 7869cf9

Browse files
Merge pull request nodegit#1922 from julianmesa-gitkraken/add-lto-remove-asserts
Improve performance using LTO and disabling asserts
2 parents 4b11a46 + 88d0551 commit 7869cf9

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
steps:
2121
- name: Install Dependencies for Ubuntu
2222
# git >= 2.18 required for actions/checkout git support
23-
run: apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:git-core/ppa && apt-get update && apt-get install -y git build-essential clang libssl-dev libkrb5-dev libc++-dev wget
23+
run: apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:git-core/ppa && apt-get update && apt-get install -y git build-essential clang-8 lld-8 libssl-dev libkrb5-dev libc++-dev wget
2424
env:
2525
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
2626

@@ -29,6 +29,9 @@ jobs:
2929
CC: clang
3030
CXX: clang++
3131
run: |
32+
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 100
33+
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 100
34+
update-alternatives --install /usr/bin/ld ld /usr/bin/lld-8 100
3235
mkdir ~/python
3336
cd ~/python
3437
wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
@@ -65,10 +68,17 @@ jobs:
6568
CXX: clang++
6669
npm_config_clang: 1
6770
GYP_DEFINES: use_obsolete_asm=true
71+
AR: "/usr/lib/llvm-8/bin/llvm-ar"
72+
NM: "/usr/lib/llvm-8/bin/llvm-nm"
73+
# ranlib is not needed, and doesn't support .bc files in .a
74+
RANLIB: /bin/true
6875
# There is a race condition in node/generate that needs to be fixed
6976
# Node 16 changed the logic it uses to select it's UID which means to make node run as root and not 1001, we need to chwon the current directory. More Details:
7077
# https://stackoverflow.com/questions/70298238/getting-eaccess-when-running-npm-8-as-root
7178
run: |
79+
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 100
80+
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 100
81+
update-alternatives --install /usr/bin/ld ld /usr/bin/lld-8 100
7282
chown root.root -R .
7383
npm set unsafe-perm true
7484
node utils/retry npm install

generate/templates/templates/binding.gyp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@
77
"macOS_deployment_target": "10.11"
88
},
99

10+
'target_defaults': {
11+
'default_configuration': 'Debug',
12+
'configurations': {
13+
'Debug': {
14+
'defines': [ 'DEBUG', '_DEBUG' ],
15+
},
16+
'Release': {
17+
'defines': [ 'NDEBUG' ],
18+
'cflags': [ '-flto' ],
19+
'xcode_settings': {
20+
'LLVM_LTO': 'YES'
21+
},
22+
'msvs_settings': {
23+
'VCCLCompilerTool': {
24+
'WholeProgramOptimization': 'true'
25+
},
26+
'VCLibrarianTool': {
27+
},
28+
'VCLinkerTool': {
29+
'LinkTimeCodeGeneration': 1
30+
}
31+
}
32+
}
33+
}
34+
},
35+
1036
"targets": [
1137
{
1238
"target_name": "acquireOpenSSL",

vendor/libgit2.gyp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@
1313
"electron_openssl_root%": "<!(node ../utils/getElectronOpenSSLRoot.js <(module_root_dir))",
1414
"electron_openssl_static%": "<!(node -p \"process.platform !== 'linux' || process.env.NODEGIT_OPENSSL_STATIC_LINK === '1' ? 1 : 0\")",
1515
},
16+
'target_defaults': {
17+
'default_configuration': 'Debug',
18+
'configurations': {
19+
'Debug': {
20+
'defines': [ 'DEBUG', '_DEBUG' ],
21+
},
22+
'Release': {
23+
'defines': [ 'NDEBUG' ],
24+
'cflags': [ '-flto' ],
25+
'xcode_settings': {
26+
'LLVM_LTO': 'YES'
27+
},
28+
'msvs_settings': {
29+
'VCCLCompilerTool': {
30+
'WholeProgramOptimization': 'true'
31+
},
32+
'VCLibrarianTool': {
33+
},
34+
'VCLinkerTool': {
35+
'LinkTimeCodeGeneration': 1
36+
}
37+
}
38+
}
39+
}
40+
},
1641
"targets": [
1742
{
1843
"target_name": "libgit2",

0 commit comments

Comments
 (0)