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

273 Commits

Author SHA1 Message Date
Rui Ueyama
5621394dc3 Do not use git command in Makefile
Fixes https://github.com/rui314/mold/issues/529
2022-06-02 21:27:26 +08:00
Rui Ueyama
a98a19acfa Refactor 2022-05-13 14:09:41 +08:00
Rui Ueyama
c1409d95a4 Refactor 2022-05-12 09:30:02 +08:00
Rui Ueyama
c054e3d197 Fix CI 2022-05-11 17:23:29 +08:00
Rui Ueyama
05acf9da2c Add test-asan, test-tsan and test-ubsan targets 2022-05-11 15:51:44 +08:00
Rui Ueyama
4ef90d4316 Do not use pkg-config
We are not using pkg-config for zlib, so I think we can live without
it for libcrypto too.
2022-05-11 15:32:51 +08:00
Rui Ueyama
ab63994c97 Fix symlink name 2022-05-09 14:02:20 +08:00
Dawid Jurczak
3499ee6ac7 Add UBSan support
Core part of this change is cleaning up Mold from UBSan alignment errors.
Following approach inspired by LLVM's ELFTypes is done here:

    1. Introduce generic Packed class acting as proxy for unaligned aggregated value.
       Every access to such value through proxy is secured by memcpy call.
    2. Replace plain struct members with Packed members wherever it matters.
    3. Use explicit castings through Packed type for misaligned loads.

For more background please check: https://github.com/rui314/mold/discussions/477

Signed-off-by: Dawid Jurczak <dawid_jurek@vp.pl>
2022-04-30 17:37:14 +02:00
Rui Ueyama
c8d8f86a52 Bump mold version to 1.2.1 2022-04-28 17:51:29 +08:00
Rui Ueyama
19ad74ac52 Use python3 instead of python
If a system has only Python 3, it may not have `python` command.
2022-04-17 15:12:35 +08:00
Rui Ueyama
5803c3c200 Make /usr/local/libexec/ld really relative
Pointed out by Kévin Le Gouguec in https://github.com/rui314/mold/pull/425.
2022-04-16 17:14:55 +08:00
Rui Ueyama
8073a92614 Make /usr/local/libexec/ld a relative symlink
I didn't want to write a Python one-liner in the Makefile, but it
looks like it is in practice one of the most portable way to compute a
relative path.

https://github.com/rui314/mold/pull/425
2022-04-16 11:48:35 +08:00
Rui Ueyama
f86868cb38 Bump mold version to 1.2.0 2022-04-15 17:08:14 +08:00
Rui Ueyama
421289445a Remove dist.sh's output on make clean 2022-04-15 17:08:14 +08:00
Rui Ueyama
4df5d6497a Break down test-all into smaller targets 2022-04-09 10:21:18 +08:00
Rui Ueyama
4e10ee7e50 [ELF] Run tests for all targets on CI 2022-04-02 21:27:45 +08:00
Rui Ueyama
b6876b5640 Update comment 2022-04-01 13:12:27 +08:00
Rui Ueyama
c1af9c97e7 Bump mold version to 1.1.1 2022-03-07 19:38:14 +09:00
Rui Ueyama
89612b7096 Bump mold version to 1.1 2022-02-20 16:40:17 +09:00
Rui Ueyama
c8853223a3 Add a script to create a tar file for binary distribution
I think we don't need to create a tar file for binary distribution
for each Linux distro. Instead, we can create mold executable that
works on most Linux machines.

The new script, build-dynamic.sh, creates a mold executable with
libmimalloc, libtbb, libstdc++ and libcrypto begin linked statically.
I don't have a concern as to the availability of other libraries
(libc, libm, libz and librt) because they essentially exists on any
system.
2022-02-19 11:26:18 +09:00
Rui Ueyama
b22e6f80fc Add scripts to create binary packages
https://github.com/rui314/mold/issues/351
2022-02-18 22:11:34 +09:00
Rui Ueyama
825b918146 Do not use dlopen only when built with ./build-static.sh
This commit fixes a regression in f4a9b05114
that mold crashed when it tried to dlopen a linker plugin shared library.
2022-02-18 15:18:56 +09:00
Rui Ueyama
f4a9b05114 Do not call dloepn() if built with ./build-static.sh
It looks like setting __TBB_DYNAMIC_LOAD_ENABLED to 0 is not enough
to make TBB not to call dlopen(). We need to unset __TBB_WEAK_SYMBOLS_PRESENT
as well.

Fixes https://github.com/rui314/mold/issues/348
2022-02-18 12:17:24 +09:00
Rui Ueyama
7735cf5b95 Style change 2022-02-17 20:29:28 +09:00
Dmitry Antipov
630b262d2b Use explicit mimalloc new/delete overrides if SYSTEM_MIMALLOC
When building with SYSTEM_MIMALLOC=1, linking with (assuming
shared) '-lmimalloc' is not enough to override C++ new/delete
with mimalloc versions, and 'mimalloc-new-delete.h' should be
included from one (and the only) translation unit as well.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2022-02-17 10:44:58 +03:00
Rui Ueyama
46995bcfc3 [ELF] Support LTO plugin API
The LTO plugin API support is still in progress, but with this change,
mold can link itself with `-flto` with both GCC and Clang.

Since mold now supports LTO natively, I removed the fallback mechanism
to ld.bfd or ld.lld that I implemented in
a5029d19a8.

Fixes https://github.com/rui314/mold/issues/181
2022-02-11 21:09:28 +09:00
Rui Ueyama
6ee5aea1bf Add a comment about how to build mold with AddressSanitizer 2022-02-11 18:16:20 +09:00
Rui Ueyama
e5f4b967ed Do not link against libxxhash.so at all
Ensure that all xxhash functions are inlined. Since it eliminates
external dependencies, we no longer have to link against libxxhash.a
or libxxhash.so at all.

`SYSTEM_XXHASH` Makefile variable has been removed because it is
no longer relevant.
2022-02-07 20:06:59 +09:00
Rui Ueyama
36fe7511f1 Do not link against librt if not necessary 2022-02-07 11:32:23 +09:00
Rui Ueyama
4551fffe69 Do not link against libxxhash.so if not necessary
We use only `XXH3_64bits` from libxxhash, and it looks like the function
is an inline function, so there's actually no runtime dependency against
libxxhash.so.
2022-02-07 11:29:02 +09:00
Rui Ueyama
ab2db49fbe Refactor 2022-02-07 08:37:35 +09:00
Rui Ueyama
c6e4fb56b4 Bump mold version to 1.0.3 2022-01-30 19:57:30 +09:00
Sergei Trofimovich
bc66d9a684 Makefile: avoid calling '$(shell)' on each $(CXX) execution
Before the change calls to $(shell git rev-parse) and $(shell pkg-config)
happened on every mold's .o file (as make's "A = $(B)" performs late
expansion).

After the change $(shell) calls are evaluated once with "A := $(B)"
assignment.

Noticed by chance when 'make' was complaining about missing pkg-config
tool on each build step.

Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
2022-01-27 12:29:20 +00:00
Rui Ueyama
220161b6c6 Automatically manage source dependencies 2022-01-25 13:32:51 +09:00
Marc-Antoine Perennou
708112cd16 build-sys: allow overriding pkg-config
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2022-01-24 14:14:43 +01:00
Christoph Erhardt
0653716408 Pass CXXFLAGS to bundled tbb
This makes work easier for distributions that specify custom hardened
compiler flags.

Signed-off-by: Christoph Erhardt <github@sicherha.de>
2022-01-23 16:03:53 +01:00
Rui Ueyama
6fb64656b9 Bump mold version to 1.0.2 2022-01-23 17:19:40 +09:00
Rui Ueyama
21dd8834d3 Do not create mold as a PIE by default
It is up to packager's choice to create mold as a position-independent
executable or not. If you want, pass `LDFLAGS=-fpie` and `CXXFLAGS=-fPIE`
to `make`.
2022-01-23 16:22:15 +09:00
Rui Ueyama
c6dc8da704 Tidy up Makefile
Our Makefile didn't allow overriding CFLAGS, CXXFLAGS or LDFLAGS
because we add mandatory options to these variables. It is contrary
to conventions Makefile conventions explained here.
https://www.gnu.org/prep/standards/html_node/Command-Variables.html#Command-Variables

In this patch, I separated mandatory options to MOLD_CXXFLAGS and
MOLD_LDFLAGS so that users can freely override CFLAGS, CXXFLAGS and
LDFLAGS.

I also removed `DEBUG`, `ASAN` and `TSAN` variables from the Makefile
because we can now simply pass `CXXFLAGS="-g -O0"` or
`CXXFLAGS=-fsanitize=...` instead.
2022-01-23 15:45:48 +09:00
Rui Ueyama
28c36e58b7 Revert "Fix a build issue on Gentoo with musl libc"
This reverts commit 2cc85cc21d because
it didn't fix the Gentoo's issue.

https://github.com/rui314/mold/issues/281
2022-01-22 00:52:17 +09:00
Rui Ueyama
e3359ea415 Fix macOS buildbot 2022-01-20 16:46:08 +09:00
Rui Ueyama
2cc85cc21d Fix a build issue on Gentoo with musl libc
libtbb.so contains undefined symbols on Gentoo with musl libc.
Because we are not using such symbols at runtime, and symbols are
resolved lazily, mold would work fine as long as we can build it.
By passing `-allow-shlib-undefined`, we can build mold.

Fixes https://github.com/rui314/mold/issues/281
2022-01-20 16:35:44 +09:00
Rui Ueyama
02c9fa82d4 [ELF] Ensure mold-warpper.so is linked against libdl 2022-01-20 10:23:32 +09:00
Rui Ueyama
d8e3980b86 Do not link libdl
I don't think mold uses any functionality in libdl. mold-wrapper.so
needs it for dlopen()-family functions on non-NetBSD systems though.
2022-01-20 09:28:51 +09:00
Masatake Daimon
af05107964 Do not try to link with -ldl unconditionally
Some operating systems, like NetBSD, don't have a separate library for
dlopen(3). They have dl* functions in their libc.

Signed-off-by: Masatake Daimon <pho@NetBSD.org>
2022-01-19 11:16:55 +09:00
Rui Ueyama
5fc0e503e1 Do not use CPPFLAGS for C++ compiler flags
The correct variable name is `CXXFLAGS`. `CPPFLAGS` is for C preprocessor
flags in the Makefile.
2022-01-14 15:34:55 +09:00
Rui Ueyama
f4a37b2e95 Do not use clang/clang++ as the default compilers
mold does not have to be built with clang/clang++, so don't use
these compiler frontends.

mold also doesn't have be built with g++ (GNU C++ compiler).
We use `c++` command instead.

Fixes https://github.com/rui314/mold/issues/261
2022-01-07 18:45:05 +09:00
Rui Ueyama
1acabd65e3 Add a comment 2022-01-06 23:42:15 +09:00
Rui Ueyama
fe14a08761 Make make to take EXTRA_CFLAGS and EXTRA_CXXFLAGS 2022-01-05 21:36:48 +09:00
Rui Ueyama
31a6a1164e
Merge pull request #248 from sina-ht/use-pkg-config
Use pkg-config to know where openssl header files reside
2022-01-05 18:40:55 +09:00