mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Charlotte Delenk <darkkirb@darkkirb.de>
To: musl@lists.openwall.com
Subject: [musl] [PATCH 1/2] Fix LTO shared library build on GCC and Clang
Date: Tue, 29 Dec 2020 12:56:53 +0100	[thread overview]
Message-ID: <54089c13-88b2-6b8d-8e4a-b3e6b59075e3@darkkirb.de> (raw)
In-Reply-To: <104266ac-6da3-0fac-2394-54dca6675270@darkkirb.de>

Both GCC and Clang are currently unable to compile the musl dynamic
library with link time optimizations enabled, due to them overzealously
removing certain symbols used on program start which they deem are not
necessary.

This patch adds new link flags to the libc.so link that tell the linker
that a symbol is used externally, so that code for these functions is
always emitted.
---
  Makefile | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index e8cc4436..15190fb9 100644
--- a/Makefile
+++ b/Makefile
@@ -131,6 +131,9 @@ $(CRT_OBJS): CFLAGS_ALL += -DCRT

  $(LOBJS) $(LDSO_OBJS): CFLAGS_ALL += -fPIC

+# Work around LTO compiler bugs
+lib/libc.so: CFLAGS_ALL += -u_dlstart_c -u__dls2 -u__dls2b -u__dls3 
-u__stack_chk_guard -u_start_c
+
  CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $<

  # Choose invocation of assembler to be used
-- 
2.29.2


  reply	other threads:[~2020-12-29 11:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27 17:53 [musl] [PATCH] Add support for LLVM's Control Flow Integrity Charlotte Delenk
2020-12-27 23:05 ` Fangrui Song
2020-12-28  0:56   ` Fangrui Song
2020-12-28  9:20     ` Charlotte Delenk
2020-12-28 13:17       ` [musl] [PATCH] Add support for LLVM's Control Flow Integrity (V2) Charlotte Delenk
2020-12-28 17:01         ` Shiz
2020-12-29  1:26           ` Rich Felker
2020-12-29 10:20           ` Charlotte Delenk
2020-12-29 11:56             ` Charlotte Delenk [this message]
2020-12-29 11:59             ` [musl] [PATCH 2/2] Add support for LLVM's Control Flow Integrity Charlotte Delenk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54089c13-88b2-6b8d-8e4a-b3e6b59075e3@darkkirb.de \
    --to=darkkirb@darkkirb.de \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).