public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jim Wilson <jimw@sifive.com>
To: Peter Lamby <dev@peterlamby.de>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Compiling gcc fails while trying to link libgcc
Date: Fri, 10 Jul 2020 18:35:38 -0700	[thread overview]
Message-ID: <CAFyWVabpkVREEK4P2WOGEayvum6CBOEabt8iSTo6VfjsBA_sJQ@mail.gmail.com> (raw)
In-Reply-To: <C41YPB854LL6.28VAQJ8YQ4N30@archlinux>

On Thu, Jul 9, 2020 at 1:51 AM Peter Lamby via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> export CFLAGS=-pipe -march=native -fstack-protector-strong -fno-plt \
> -pie -fpie

You can't use -pie when linking a shared library.  So this isn't going
to work.  Also the -fno-plt is suspicious.  Can you compile a shared
library without plts?  The -fpie is clearly wrong too.  You need to do
this a different way.  Note that gcc has a configure option
--enable-default-pie which will produce pie output by default, but
won't pass -pie to the linker with -static, -shared, or -r.  And won't
add -fpie if -fpic was specified.

rohan:2242$ gcc -shared -fpic -o tmp.so tmp.c
rohan:2243$ gcc -shared -fpic -o tmp.so tmp.c -pie
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
rohan:2244$

Jim

  reply	other threads:[~2020-07-11  1:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09  8:49 Peter Lamby
2020-07-11  1:35 ` Jim Wilson [this message]
2020-07-11  7:50   ` Peter Lamby

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=CAFyWVabpkVREEK4P2WOGEayvum6CBOEabt8iSTo6VfjsBA_sJQ@mail.gmail.com \
    --to=jimw@sifive.com \
    --cc=dev@peterlamby.de \
    --cc=gcc-help@gcc.gnu.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).