1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-21 18:08:01 +03:00
Commit Graph

2739 Commits

Author SHA1 Message Date
Rui Ueyama
d1422a03e2 Check if libxxhash exists 2021-07-21 00:02:44 +09:00
Rui Ueyama
e13b1180af Make cmake to accept -DMOLD_BUILD_STATIC_EXE flags 2021-07-20 23:22:27 +09:00
Rui Ueyama
33fef23ffb Enable assert() for release builds
Our assert() statements are pretty cheap. We want to enable them
even for release builds.

By default, cmake passes -DNDEBUG to disable assert() for release
builds. So, in this patch, we undefine it to re-enable assertions.
2021-07-20 21:13:03 +09:00
Rui Ueyama
9e78e4a792 Update README 2021-07-20 19:46:45 +09:00
Rui Ueyama
800aba8312 Update README 2021-07-20 15:33:57 +09:00
Rui Ueyama
6254d7def3 Make CI to use cmake instead of make 2021-07-20 14:08:07 +09:00
Rui Ueyama
81ea1d407a Make cmake to accept -DMOLD_USE_SYSTEM_{MIMALLOC,TBB} flags 2021-07-20 13:43:02 +09:00
Rui Ueyama
271c9151f4 Disable tests for mold-wrapper if ASAN is enabled
ASAN doens't work well if other libraries are LD_PRELOAD'ed.
2021-07-20 13:32:02 +09:00
Rui Ueyama
59822bf07e Attempt to fix CI 2021-07-20 00:43:14 +09:00
Rui Ueyama
fe26dad744 Fix cmake build
You can now build mold with the following commands:

  $ mkdir -p out/debug
  $ cd out/debug
  $ cmake -GNinja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug ../..
  $ ninja

To run tests, use the following commands:

  $ cd out/debug
  $ ctest -j$(nproc)
2021-07-20 00:33:28 +09:00
Rui Ueyama
4d81fdd4d8
Merge pull request #49 from 3a2l/cmake
Add CMake support
2021-07-20 00:08:57 +09:00
Rui Ueyama
2bf2da4822 Refactor 2021-07-18 20:01:55 +09:00
Rui Ueyama
e9c6a08e1e Use more relaxed memory store to flip "is_alive" flag
By default, std::atomic<T>::operator=() stores a given value with
the sequentially-consistent memory ordering, which is a very strong
memory order. We only need the atomicity of store in this case,
so we can use memory_order_relaxed instead.

This change improves performance when we have a lot of section
fragments.

This change shortens the time for garbage collection for clang-13
from 170ms to 100ms.
2021-07-18 14:56:25 +09:00
Rui Ueyama
afc1fe6645 Update README 2021-07-17 15:09:16 +09:00
Rui Ueyama
c0c2e1409c
Merge pull request #95 from tbillington/patch-1
include example of linking rust code
2021-07-17 15:08:36 +09:00
Rui Ueyama
bb989791a7 Update .gitignore 2021-07-17 01:24:23 +09:00
Rui Ueyama
04e9aa4ebc Skip i386/aarch64 tests if cross compilers are not available
https://github.com/rui314/mold/issues/89
2021-07-17 01:23:58 +09:00
Trent
abb1258ee2
include example of linking rust code 2021-07-16 23:00:12 +10:00
Rui Ueyama
c220909e1b Improve Gentoo test script 2021-07-16 16:26:41 +09:00
Rui Ueyama
cce1cb353f Fill .rela.dyn even if there's no .got 2021-07-16 15:43:37 +09:00
Rui Ueyama
c44fa6172b Recognize yet another crt{begin,end}.o variant
Looks like musl libc sometimes uses crtbeginT.o and crtendT.o.
2021-07-16 15:43:21 +09:00
Rui Ueyama
280892f061 Fix tests for musl 2021-07-16 15:30:54 +09:00
Rui Ueyama
bedb2f55f9 Fix header path
"sys/signal.h" happens to work with GNU libc, but the correct path
is "signal.h".
2021-07-16 15:26:21 +09:00
Rui Ueyama
dca0e6b7ad Do out-of-tree build for tbb and mimalloc
So that the build directory is less scattered.
2021-07-16 15:10:59 +09:00
Rui Ueyama
1713f6e2f7 Rename oneTBB tbb
"oneTBB" used to be a git submodule, and it is now just a subdirectory.
Using the same directory name makes it difficult to switch between
branches. So I rename it "tbb".
2021-07-16 15:10:59 +09:00
Rui Ueyama
3a7b0525c7 Make it build with musl
musl does not provide makecontext() and swapcontext(), though
they were once in POSIX. They were removed from POSIX.2008 though.
2021-07-16 15:10:59 +09:00
Rui Ueyama
7937360c6a Avoid "PAGE_SIZE" as an identifier
musl libc uses PAGE_SIZE as a macro name, so use other name as
a variable name.
2021-07-16 15:10:59 +09:00
Rui Ueyama
fb100f21b3 Do not print out stacktrace on crash
This commit partially reverts e855b90344
because that change was not portable to non-glibc systems.
2021-07-16 14:33:20 +09:00
Rui Ueyama
fa543ae350 Attempt to fix a breakage
It looks like 564d7e044ff8a2534a2413d34762dd84be7eaf66 introduced
a concurrency issue.
2021-07-16 14:31:12 +09:00
Rui Ueyama
d8ad600b6a Improve MergedSection<E>::assign_offsets()
This patch parallelize MergedSection<E>::assign_offsets().
clang-13 link time is reduced from ~2.5s to ~2.35 with this patch.
2021-07-14 17:11:25 +09:00
Rui Ueyama
d79cdb8371 Fix a broken test
Fixes https://github.com/rui314/mold/issues/89
2021-07-13 19:24:26 +09:00
Rui Ueyama
41b2fa7375 Optimize string merging
Linking clang-13 with debug info takes ~3.6 seconds on a simulated
10-core/20-threads machine. mold spends most of its time (~2.3 seconds)
merging string literals in .debug_str. Input .debug_str sections contain
70 million string literals in total, which is reduced to 2 million after
de-duplication. The input object files contain a lot of duplicates.
clang-13 with debug info is enormous -- it is ~3.1 GiB after linking.

It looks like TBB's concurrent hashmap doesn't scale well with the
input.

In this patch, I implemented our own concurrent hashmap. The hashmap
is extremely lightweight and support only the key-value insertion
operation. It doesn't even support rehashing. It aborts once the hash
table becomes full.

In order to know the correct size for the hashmap before inserting
strings into it, I also implemented HyperLogLog algorithm in this patch.
HyperLogLog is an algorithm that gives a fairly accurate estimate on
the number of unique elements.

With this patch, mold can link clang-13 in ~2.5 seconds, which is ~30%
faster than before.

https://github.com/rui314/mold/issues/73
2021-07-13 16:54:09 +09:00
Rui Ueyama
6bb091595e Refactor 2021-07-13 13:13:34 +09:00
Rui Ueyama
ecbd3eae14
Merge pull request #87 from Logarithmus/fix-run-sh
Fix test/run.sh for cases when /usr/bin/ld -> /usr/bin/mold
2021-07-12 13:49:39 +09:00
Artur Sinila
5fb7ecbd03
Fix test/run.sh for cases when /usr/bin/ld -> /usr/bin/mold
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-12 05:27:21 +03:00
Rui Ueyama
e0d44b6678 Use concurrent_unorderd_map for string merging
With high contention rate, it looks like concurrent_unordered_map
outperforms concurrent_hash_map.
2021-07-12 00:02:01 +09:00
Rui Ueyama
3204bb01d9 Fix function pointer equality
Previously, a GOT relocation (e.g. R_X86_64_REX_GOTPCRELX) and a
R_X86_64_64 relocation referring the same imported symbols were
resolved to different addresses. Here is why:

 - When we saw a R_X86_64_64 relocation against an imported symbol,
   we created a PLT and resolve the relocation there.

 - GOT relocation is resolved to a GOT entry, which has a true
   address of an imported function at runtime, which is different
   from PLT entries that redirect calls to the real function.

With this patch, we no longer create a PLT entry for R_X86_64_64.
Instead, we emit a dynamic relocation so that it is always resolved
to a real function address.

Fixes GNU MP's `make check` failure, which was reported at
https://github.com/rui314/mold/issues/81
2021-07-10 17:54:57 +09:00
Rui Ueyama
faac31f217 Support VERSION linker script command
The grammar of the command is this

  VERSION { <version-script> }

where <version-script> is a version script you can specify with
the --version-script option.
2021-07-09 23:34:44 +09:00
Rui Ueyama
e855b90344 Show stacktrace on SEGV and assertion failure 2021-07-09 23:34:39 +09:00
Rui Ueyama
63b6d30876 Compress .repro section contents
Previously, .repro contains an uncompressed tar file containing all
input files. This patch compresses the contents in the gzip format.
2021-07-09 00:47:15 +09:00
Rui Ueyama
3acb7c8e2f Update README
Pointed out by @pecak.
2021-07-08 17:17:10 +09:00
Rui Ueyama
50b7497e19 Align section header to a E::wordsize boundary
Fixes https://github.com/rui314/mold/issues/80
2021-07-08 15:58:55 +09:00
Rui Ueyama
64913ba610
Merge pull request #77 from Logarithmus/fix-tests
Optimize CI build (enable ccache & run tests in parallel)
2021-07-08 00:43:40 +09:00
Artur Sinila
f9a5e9171e
ci.yml: enable ccache
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-07 18:37:14 +03:00
Artur Sinila
67948ac222
ci.yml: run tests in parallel
Signed-off-by: Artur Sinila <freesoftware@logarithmus.dev>
2021-07-07 18:37:14 +03:00
Rui Ueyama
84d9e4d5ac Fix regexp 2021-07-07 23:12:24 +09:00
Rui Ueyama
72cc07fb42
Merge pull request #83 from nehaljwani/dynsym-IFUNC
Do not replace IFUNC with FUNC in .dynsym
2021-07-07 21:48:15 +09:00
Rui Ueyama
057fffb1dd Optimize regexes 2021-07-07 21:46:23 +09:00
Rui Ueyama
6ae115ac69 Support R_AARCH_ABS{32,64} relocations 2021-07-07 21:06:18 +09:00
Nehal J Wani
1aec54efdb
Do not replace IFUNC with FUNC in .dynsym
This is a partial revert of dd04357

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-07 07:59:51 -04:00