All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
@ 2020-12-24 10:14 Fabrice Fontaine
  2020-12-28 21:53 ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Fabrice Fontaine @ 2020-12-24 10:14 UTC (permalink / raw)
  To: buildroot

Fixes:
 - http://autobuild.buildroot.org/results/9ac6e1bf9eaf922c0b7f869416ec33f40ed3543c

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 .../0001-rebar.config-add-fPIC.patch          | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 package/erlang-jiffy/0001-rebar.config-add-fPIC.patch

diff --git a/package/erlang-jiffy/0001-rebar.config-add-fPIC.patch b/package/erlang-jiffy/0001-rebar.config-add-fPIC.patch
new file mode 100644
index 0000000000..4809cad03b
--- /dev/null
+++ b/package/erlang-jiffy/0001-rebar.config-add-fPIC.patch
@@ -0,0 +1,43 @@
+From 18a2ec2ab855e4762c4adab9a86ec6f601e35de9 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Thu, 24 Dec 2020 10:57:54 +0100
+Subject: [PATCH] rebar.config: add -fPIC
+
+Add -fPIC to avoid the following build failure:
+
+/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: /tmp/cc0ULrdG.ltrans1.ltrans.o: relocation R_X86_64_PC32 against symbol `dec_destroy' can not be used when making a shared object; recompile with -fPIC
+/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: final link failed: bad value
+collect2: error: ld returned 1 exit status
+sh(/home/buildroot/autobuild/instance-3/output-1/host/bin/x86_64-linux-g++ c_src/decoder.o c_src/encoder.o c_src/jiffy.o c_src/termstack.o c_src/utf8.o c_src/util.o c_src/doubles.o c_src/objects.o c_src/double-conversion/bignum-dtoa.o c_src/double-conversion/bignum.o c_src/double-conversion/cached-powers.o c_src/double-conversion/diy-fp.o c_src/double-conversion/double-conversion.o c_src/double-conversion/fast-dtoa.o c_src/double-conversion/fixed-dtoa.o c_src/double-conversion/strtod.o  -flto -lstdc++ -flto -lstdc++ -shared  -L/home/buildroot/autobuild/instance-3/output-1/host/x86_64-buildroot-linux-uclibc/sysroot/usr/lib/erlang/lib/erl_interface-3.13.1/lib -lei -o priv/jiffy.so)
+failed with return code 1 and the following output:
+/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: /tmp/cc0ULrdG.ltrans1.ltrans.o: relocation R_X86_64_PC32 against symbol `dec_destroy' can not be used when making a shared object; recompile with -fPIC
+/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: final link failed: bad value
+collect2: error: ld returned 1 exit status
+
+ERROR: Command [compile] failed!
+
+Fixes:
+ - http://autobuild.buildroot.org/results/9ac6e1bf9eaf922c0b7f869416ec33f40ed3543c
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: https://github.com/davisp/jiffy/pull/208]
+---
+ rebar.config | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/rebar.config b/rebar.config
+index b951b5e..8bff5e7 100644
+--- a/rebar.config
++++ b/rebar.config
+@@ -15,7 +15,7 @@
+         "CXXFLAGS", "$CXXFLAGS -Ic_src/ -g -Wall $FLTO_FLAG -Werror -O3"},
+ 
+     {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
+-        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++"},
++        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++ -fPIC"},
+ 
+     %% OS X Leopard flags for 64-bit
+     {"darwin9.*-64$", "CXXFLAGS", "-m64"},
+-- 
+2.29.2
+
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2020-12-24 10:14 [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC Fabrice Fontaine
@ 2020-12-28 21:53 ` Thomas Petazzoni
  2020-12-29  9:39   ` Fabrice Fontaine
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-12-28 21:53 UTC (permalink / raw)
  To: buildroot

Hello Fabrice,

On Thu, 24 Dec 2020 11:14:40 +0100
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> Fixes:
>  - http://autobuild.buildroot.org/results/9ac6e1bf9eaf922c0b7f869416ec33f40ed3543c
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Thanks for the patch. As usual, I'm kind of interested to understand
since when this is happening, why suddenly we need a fix like this. Is
this following a version bump of this package ?

> +     {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
> +-        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++"},
> ++        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++ -fPIC"},

It is surprising that only LDFLAGS need to be changed. Indeed, -fPIC is
also needed at *compile* time when compiling each individual object
file, so typically in CFLAGS/CXXFLAGS. Why isn't it needed in CXXFLAGS
here ? Because it's already passed at compile time, but forgotten at
link time ? Or because LDFLAGS are also used by rebar at compile time ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2020-12-28 21:53 ` Thomas Petazzoni
@ 2020-12-29  9:39   ` Fabrice Fontaine
  2020-12-29  9:43     ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Fabrice Fontaine @ 2020-12-29  9:39 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

Le lun. 28 d?c. 2020 ? 22:53, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> a ?crit :
>
> Hello Fabrice,
>
> On Thu, 24 Dec 2020 11:14:40 +0100
> Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
>
> > Fixes:
> >  - http://autobuild.buildroot.org/results/9ac6e1bf9eaf922c0b7f869416ec33f40ed3543c
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
>
> Thanks for the patch. As usual, I'm kind of interested to understand
> since when this is happening, why suddenly we need a fix like this. Is
> this following a version bump of this package ?
>
> > +     {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
> > +-        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++"},
> > ++        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++ -fPIC"},
>
> It is surprising that only LDFLAGS need to be changed. Indeed, -fPIC is
> also needed at *compile* time when compiling each individual object
> file, so typically in CFLAGS/CXXFLAGS. Why isn't it needed in CXXFLAGS
> here ? Because it's already passed at compile time, but forgotten at
> link time ? Or because LDFLAGS are also used by rebar at compile time ?
This build failure is raised because of the -flto flag which is added
since version 1.0.0 and
https://github.com/davisp/jiffy/commit/feaf10f2d50e454f55a9d6b20c289031b0980503
It seems that -flto can't be used without -fPIC.
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Best Regards,

Fabrice

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2020-12-29  9:39   ` Fabrice Fontaine
@ 2020-12-29  9:43     ` Thomas Petazzoni
  2020-12-29 10:14       ` Fabrice Fontaine
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-12-29  9:43 UTC (permalink / raw)
  To: buildroot

On Tue, 29 Dec 2020 10:39:27 +0100
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> This build failure is raised because of the -flto flag which is added
> since version 1.0.0 and
> https://github.com/davisp/jiffy/commit/feaf10f2d50e454f55a9d6b20c289031b0980503
> It seems that -flto can't be used without -fPIC.

This seems super odd. I'm not sure what would be the relationship
between LTO and PIC...

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2020-12-29  9:43     ` Thomas Petazzoni
@ 2020-12-29 10:14       ` Fabrice Fontaine
  2021-01-01 10:01         ` Yann E. MORIN
  0 siblings, 1 reply; 8+ messages in thread
From: Fabrice Fontaine @ 2020-12-29 10:14 UTC (permalink / raw)
  To: buildroot

Le mar. 29 d?c. 2020 ? 10:43, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> a ?crit :
>
> On Tue, 29 Dec 2020 10:39:27 +0100
> Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
>
> > This build failure is raised because of the -flto flag which is added
> > since version 1.0.0 and
> > https://github.com/davisp/jiffy/commit/feaf10f2d50e454f55a9d6b20c289031b0980503
> > It seems that -flto can't be used without -fPIC.
>
> This seems super odd. I'm not sure what would be the relationship
> between LTO and PIC...
Indeed but the build failure is fixed if I remove -flto from CFLAGS.
I'll try to understand why ...
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Best Regards,

Fabrice

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2020-12-29 10:14       ` Fabrice Fontaine
@ 2021-01-01 10:01         ` Yann E. MORIN
  2021-01-01 10:37           ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Yann E. MORIN @ 2021-01-01 10:01 UTC (permalink / raw)
  To: buildroot

Fabrice, Thomas, All,

On 2020-12-29 11:14 +0100, Fabrice Fontaine spake thusly:
> Le mar. 29 d?c. 2020 ? 10:43, Thomas Petazzoni
> <thomas.petazzoni@bootlin.com> a ?crit :
> >
> > On Tue, 29 Dec 2020 10:39:27 +0100
> > Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
> >
> > > This build failure is raised because of the -flto flag which is added
> > > since version 1.0.0 and
> > > https://github.com/davisp/jiffy/commit/feaf10f2d50e454f55a9d6b20c289031b0980503
> > > It seems that -flto can't be used without -fPIC.
> >
> > This seems super odd. I'm not sure what would be the relationship
> > between LTO and PIC...
> Indeed but the build failure is fixed if I remove -flto from CFLAGS.
> I'll try to understand why ...

The thing with LTO, is that all files should (but in practice: must) be
compiled with the same set of options; from the gcc man page:

    It is recommended that you compile all the files participating in
    the same link with the same options and also specify those options
    at link time.

and later:

    There are some code generation flags preserved by GCC when generating
    bytecodes, as they need to be used during the final link. Currently,
    the following options and their settings are taken from the first
    object file that explicitly specifies them: -fPIC, [...]

So, if one file is compiled with -fPIC, then this is recorded in the .o
for that file, which gcc notices later when doing the link, and thus all
files must be -fPIC.

This can be a file compiled by the package itself, or it may come from
an external (staging) static library.

Regards,
Yann E. MORIN.

> >
> > Thomas
> > --
> > Thomas Petazzoni, CTO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
> Best Regards,
> 
> Fabrice
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2021-01-01 10:01         ` Yann E. MORIN
@ 2021-01-01 10:37           ` Thomas Petazzoni
  2021-03-02 22:49             ` Arnout Vandecappelle
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2021-01-01 10:37 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 1 Jan 2021 11:01:53 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> The thing with LTO, is that all files should (but in practice: must) be
> compiled with the same set of options; from the gcc man page:
> 
>     It is recommended that you compile all the files participating in
>     the same link with the same options and also specify those options
>     at link time.
> 
> and later:
> 
>     There are some code generation flags preserved by GCC when generating
>     bytecodes, as they need to be used during the final link. Currently,
>     the following options and their settings are taken from the first
>     object file that explicitly specifies them: -fPIC, [...]
> 
> So, if one file is compiled with -fPIC, then this is recorded in the .o
> for that file, which gcc notices later when doing the link, and thus all
> files must be -fPIC.
> 
> This can be a file compiled by the package itself, or it may come from
> an external (staging) static library.

Ah, this is indeed an interesting explanation, which could explain why
adding it just to LDFLAGS solves the problem.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC
  2021-01-01 10:37           ` Thomas Petazzoni
@ 2021-03-02 22:49             ` Arnout Vandecappelle
  0 siblings, 0 replies; 8+ messages in thread
From: Arnout Vandecappelle @ 2021-03-02 22:49 UTC (permalink / raw)
  To: buildroot



On 01/01/2021 11:37, Thomas Petazzoni wrote:
> Hello,
> 
> On Fri, 1 Jan 2021 11:01:53 +0100
> "Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> 
>> The thing with LTO, is that all files should (but in practice: must) be
>> compiled with the same set of options; from the gcc man page:
>>
>>     It is recommended that you compile all the files participating in
>>     the same link with the same options and also specify those options
>>     at link time.
>>
>> and later:
>>
>>     There are some code generation flags preserved by GCC when generating
>>     bytecodes, as they need to be used during the final link. Currently,
>>     the following options and their settings are taken from the first
>>     object file that explicitly specifies them: -fPIC, [...]
>>
>> So, if one file is compiled with -fPIC, then this is recorded in the .o
>> for that file, which gcc notices later when doing the link, and thus all
>> files must be -fPIC.
>>
>> This can be a file compiled by the package itself, or it may come from
>> an external (staging) static library.
> 
> Ah, this is indeed an interesting explanation, which could explain why
> adding it just to LDFLAGS solves the problem.

 I dove a bit into this.

 erlang-jiffy indeed enables LTO if the compiler supports it.

 It passes -fPIC during build, but not during link. This particular build
failure was with BR2_PIC_PIE=y - for some reason, when BR2_PIC_PIE is not set,
-FPIC *is* called during link already... And in fact, the addition of -fPIC
during link has the effect of cancelling the -fPIE that the toolchain wrapper
would otherwise add. Without BR2_PIC_PIE=y, the build succeeds even though no
-fPIC is passed during link. So the problem really is that BR2_PIC_PIE adds
-fPIE during link but not during build.

 However, the real question is: why does rebar add -fPIC during build but not
during link? I think this is something that should be fixed at the level of
rebar itself, not in individual packages.


 Regards,
 Arnout

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-02 22:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-24 10:14 [Buildroot] [PATCH 1/1] package/erlang-jiffy: needs -fPIC Fabrice Fontaine
2020-12-28 21:53 ` Thomas Petazzoni
2020-12-29  9:39   ` Fabrice Fontaine
2020-12-29  9:43     ` Thomas Petazzoni
2020-12-29 10:14       ` Fabrice Fontaine
2021-01-01 10:01         ` Yann E. MORIN
2021-01-01 10:37           ` Thomas Petazzoni
2021-03-02 22:49             ` Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.