mirror of
https://github.com/rui314/mold.git
synced 2024-11-10 10:57:55 +03:00
Refactor
This commit is contained in:
parent
c74b2197f9
commit
5e3f526bc1
10
Makefile
10
Makefile
@ -6,12 +6,9 @@ ifeq ($(origin CXX), default)
|
||||
CXX = clang++
|
||||
endif
|
||||
|
||||
GIT_HASH ?= $(shell [ -d .git ] && git rev-parse HEAD)
|
||||
|
||||
OS ?= $(shell uname -s)
|
||||
|
||||
CPPFLAGS = -pthread -std=c++20 -fPIE -DMOLD_VERSION=\"0.9.6\" \
|
||||
-DGIT_HASH=\"$(GIT_HASH)\" $(EXTRA_CPPFLAGS)
|
||||
CPPFLAGS = -pthread -std=c++20 -fPIE -DMOLD_VERSION=\"0.9.6\" $(EXTRA_CPPFLAGS)
|
||||
LDFLAGS += $(EXTRA_LDFLAGS)
|
||||
LIBS = -pthread -lz -lxxhash -ldl -lm
|
||||
|
||||
@ -26,6 +23,11 @@ LTO ?= 0
|
||||
ASAN ?= 0
|
||||
TSAN ?= 0
|
||||
|
||||
GIT_HASH ?= $(shell [ -d .git ] && git rev-parse HEAD)
|
||||
ifneq ($(GIT_HASH),)
|
||||
CPPFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CPPFLAGS += -O0 -g
|
||||
else
|
||||
|
@ -454,13 +454,13 @@ void parse_nonpositional_args(Context<E> &ctx,
|
||||
} else if (read_arg(ctx, args, arg, "no-dynamic-linker")) {
|
||||
ctx.arg.dynamic_linker = "";
|
||||
} else if (read_flag(args, "v")) {
|
||||
SyncOut(ctx) << get_version_string();
|
||||
SyncOut(ctx) << mold_version;
|
||||
version_shown = true;
|
||||
} else if (read_flag(args, "version")) {
|
||||
SyncOut(ctx) << get_version_string();
|
||||
SyncOut(ctx) << mold_version;
|
||||
exit(0);
|
||||
} else if (read_flag(args, "V")) {
|
||||
SyncOut(ctx) << get_version_string()
|
||||
SyncOut(ctx) << mold_version
|
||||
<< "\n Supported emulations:\n elf_x86_64\n elf_i386";
|
||||
version_shown = true;
|
||||
} else if (read_arg(ctx, args, arg, "m")) {
|
||||
|
@ -1792,7 +1792,7 @@ void ReproSection<E>::update_shdr(Context<E> &ctx) {
|
||||
TarFile tar("repro");
|
||||
|
||||
tar.append("response.txt", save_string(ctx, create_response_file(ctx)));
|
||||
tar.append("version.txt", save_string(ctx, get_version_string() + "\n"));
|
||||
tar.append("version.txt", save_string(ctx, mold_version + "\n"));
|
||||
|
||||
std::unordered_set<std::string> seen;
|
||||
for (std::unique_ptr<MemoryMappedFile<E>> &mb : ctx.owning_mbs) {
|
||||
|
@ -224,7 +224,7 @@ void compute_merged_section_sizes(Context<E> &ctx) {
|
||||
}
|
||||
|
||||
// Add an identification string to .comment.
|
||||
add_comment_string(ctx, get_version_string());
|
||||
add_comment_string(ctx, mold_version);
|
||||
|
||||
// Embed command line arguments for debugging.
|
||||
if (char *env = getenv("MOLD_DEBUG"); env && env[0])
|
||||
|
12
main.cc
12
main.cc
@ -12,12 +12,12 @@ std::string_view errno_string() {
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string get_version_string() {
|
||||
if (GIT_HASH[0] == '\0')
|
||||
return "mold " MOLD_VERSION " (compatible with GNU ld and GNU gold)";
|
||||
return "mold " MOLD_VERSION " (" GIT_HASH
|
||||
"; compatible with GNU ld and GNU gold)";
|
||||
}
|
||||
const std::string mold_version =
|
||||
#ifdef GIT_HASH
|
||||
"mold " MOLD_VERSION " (" GIT_HASH "; compatible with GNU ld and GNU gold)";
|
||||
#else
|
||||
"mold " MOLD_VERSION " (compatible with GNU ld and GNU gold)";
|
||||
#endif
|
||||
|
||||
void cleanup() {
|
||||
if (output_tmpfile)
|
||||
|
Loading…
Reference in New Issue
Block a user