From 062f80eb9d78e50e0d8b0d8767ea4295535663c2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 7 Jun 2024 14:36:44 +0900 Subject: [PATCH] Exclude atexit.c from LTO This fixes a failure in wasi-sdk "make check". ("undefined symbol: __cxa_atexit" for ctors_dtors.c test) --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 22dc6cbd..5e0c4781 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,11 @@ LIBC_TOP_HALF_MUSL_SOURCES = \ $(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/complex/*.c)) \ $(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/crypt/*.c) +LIBC_NONLTO_SOURCES = \ + $(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \ + exit/atexit.c \ + ) + ifeq ($(WASI_SNAPSHOT), p2) LIBC_TOP_HALF_MUSL_SOURCES += \ $(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \ @@ -474,6 +479,7 @@ LIBWASI_EMULATED_SIGNAL_MUSL_OBJS = $(call objs,$(LIBWASI_EMULATED_SIGNAL_MUSL_S LIBDL_OBJS = $(call objs,$(LIBDL_SOURCES)) LIBSETJMP_OBJS = $(call objs,$(LIBSETJMP_SOURCES)) LIBC_BOTTOM_HALF_CRT_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_CRT_SOURCES)) +LIBC_NONLTO_OBJS = $(call objs,$(LIBC_NONLTO_SOURCES)) # These variables describe the locations of various files and # directories in the generated sysroot tree. @@ -652,6 +658,8 @@ $(SYSROOT_LIB)/libsetjmp.a: $(LIBSETJMP_OBJS) $(PIC_OBJS): CFLAGS += -fPIC -fvisibility=default +$(LIBC_NONLTO_OBJS): CFLAGS += -fno-lto + $(MUSL_PRINTSCAN_OBJS): CFLAGS += \ -D__wasilibc_printscan_no_long_double \ -D__wasilibc_printscan_full_support_option="\"add -lc-printscan-long-double to the link command\""