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++
|
CXX = clang++
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GIT_HASH ?= $(shell [ -d .git ] && git rev-parse HEAD)
|
|
||||||
|
|
||||||
OS ?= $(shell uname -s)
|
OS ?= $(shell uname -s)
|
||||||
|
|
||||||
CPPFLAGS = -pthread -std=c++20 -fPIE -DMOLD_VERSION=\"0.9.6\" \
|
CPPFLAGS = -pthread -std=c++20 -fPIE -DMOLD_VERSION=\"0.9.6\" $(EXTRA_CPPFLAGS)
|
||||||
-DGIT_HASH=\"$(GIT_HASH)\" $(EXTRA_CPPFLAGS)
|
|
||||||
LDFLAGS += $(EXTRA_LDFLAGS)
|
LDFLAGS += $(EXTRA_LDFLAGS)
|
||||||
LIBS = -pthread -lz -lxxhash -ldl -lm
|
LIBS = -pthread -lz -lxxhash -ldl -lm
|
||||||
|
|
||||||
@ -26,6 +23,11 @@ LTO ?= 0
|
|||||||
ASAN ?= 0
|
ASAN ?= 0
|
||||||
TSAN ?= 0
|
TSAN ?= 0
|
||||||
|
|
||||||
|
GIT_HASH ?= $(shell [ -d .git ] && git rev-parse HEAD)
|
||||||
|
ifneq ($(GIT_HASH),)
|
||||||
|
CPPFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CPPFLAGS += -O0 -g
|
CPPFLAGS += -O0 -g
|
||||||
else
|
else
|
||||||
|
@ -454,13 +454,13 @@ void parse_nonpositional_args(Context<E> &ctx,
|
|||||||
} else if (read_arg(ctx, args, arg, "no-dynamic-linker")) {
|
} else if (read_arg(ctx, args, arg, "no-dynamic-linker")) {
|
||||||
ctx.arg.dynamic_linker = "";
|
ctx.arg.dynamic_linker = "";
|
||||||
} else if (read_flag(args, "v")) {
|
} else if (read_flag(args, "v")) {
|
||||||
SyncOut(ctx) << get_version_string();
|
SyncOut(ctx) << mold_version;
|
||||||
version_shown = true;
|
version_shown = true;
|
||||||
} else if (read_flag(args, "version")) {
|
} else if (read_flag(args, "version")) {
|
||||||
SyncOut(ctx) << get_version_string();
|
SyncOut(ctx) << mold_version;
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (read_flag(args, "V")) {
|
} 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";
|
<< "\n Supported emulations:\n elf_x86_64\n elf_i386";
|
||||||
version_shown = true;
|
version_shown = true;
|
||||||
} else if (read_arg(ctx, args, arg, "m")) {
|
} else if (read_arg(ctx, args, arg, "m")) {
|
||||||
|
@ -1792,7 +1792,7 @@ void ReproSection<E>::update_shdr(Context<E> &ctx) {
|
|||||||
TarFile tar("repro");
|
TarFile tar("repro");
|
||||||
|
|
||||||
tar.append("response.txt", save_string(ctx, create_response_file(ctx)));
|
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;
|
std::unordered_set<std::string> seen;
|
||||||
for (std::unique_ptr<MemoryMappedFile<E>> &mb : ctx.owning_mbs) {
|
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 an identification string to .comment.
|
||||||
add_comment_string(ctx, get_version_string());
|
add_comment_string(ctx, mold_version);
|
||||||
|
|
||||||
// Embed command line arguments for debugging.
|
// Embed command line arguments for debugging.
|
||||||
if (char *env = getenv("MOLD_DEBUG"); env && env[0])
|
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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_version_string() {
|
const std::string mold_version =
|
||||||
if (GIT_HASH[0] == '\0')
|
#ifdef GIT_HASH
|
||||||
return "mold " MOLD_VERSION " (compatible with GNU ld and GNU gold)";
|
"mold " MOLD_VERSION " (" GIT_HASH "; compatible with GNU ld and GNU gold)";
|
||||||
return "mold " MOLD_VERSION " (" GIT_HASH
|
#else
|
||||||
"; compatible with GNU ld and GNU gold)";
|
"mold " MOLD_VERSION " (compatible with GNU ld and GNU gold)";
|
||||||
}
|
#endif
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
if (output_tmpfile)
|
if (output_tmpfile)
|
||||||
|
3
mold.h
3
mold.h
@ -30,8 +30,9 @@ inline char *output_tmpfile;
|
|||||||
inline char *socket_tmpfile;
|
inline char *socket_tmpfile;
|
||||||
inline thread_local bool opt_demangle;
|
inline thread_local bool opt_demangle;
|
||||||
|
|
||||||
|
extern const std::string mold_version;
|
||||||
|
|
||||||
std::string_view errno_string();
|
std::string_view errno_string();
|
||||||
std::string get_version_string();
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void install_signal_handler();
|
void install_signal_handler();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user