1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-10 10:57:55 +03:00
This commit is contained in:
Rui Ueyama 2021-09-28 16:40:05 +09:00
parent c74b2197f9
commit 5e3f526bc1
6 changed files with 19 additions and 16 deletions

View File

@ -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

View File

@ -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")) {

View File

@ -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) {

View File

@ -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
View File

@ -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)

3
mold.h
View File

@ -30,8 +30,9 @@ inline char *output_tmpfile;
inline char *socket_tmpfile;
inline thread_local bool opt_demangle;
extern const std::string mold_version;
std::string_view errno_string();
std::string get_version_string();
void cleanup();
void install_signal_handler();