buildroot.busybox.net archive mirror
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code detected -- cannot go further'
@ 2024-01-01 21:34 Aleksandr Makarov
  2024-01-13 21:13 ` Peter Korsgaard
  0 siblings, 1 reply; 3+ messages in thread
From: Aleksandr Makarov @ 2024-01-01 21:34 UTC (permalink / raw)
  To: buildroot; +Cc: Aleksandr Makarov

Forcing HAPROXY_CFLAGS on the haproxy build command line overrides CFLAGS
which were internally set by the package Makefile.

In such a way, a bunch of flags that were deduced by the package build script
in *_CFLAGS variables, specifically in SPEC_CFLAGS, are omitted. Compiling and
running haproxy without SPEC_CFLAGS taken into account results in runtime error:

$ haproxy
FATAL ERROR: invalid code detected -- cannot go further, please recompile!
The source code was miscompiled by the compiler, which usually indicates that
some of the CFLAGS needed to work around overzealous compiler optimizations
were overwritten at build time. Please do not force CFLAGS, and read Makefile
and INSTALL files to decide on the best way to pass your local build options.
...

This error is produced by haproxy.c [1] source which effectively ensures that INT_MAX+1
expression wraps around using twos-complement representation. It is only true when -fwrapv
gcc option is set in SPEC_CFLAGS.

To address this, append necessary *_CFLAGS variables to the CFLAGS in haproxy Makefile.

[1] https://git.haproxy.org/?p=haproxy.git;a=blob;f=src/haproxy.c;h=e1863255422459e806f7e50828e81976bb41c14c;hb=HEAD#l3304

Signed-off-by: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
---
 ...fix-runtime-FATAL-ERROR-invalid-code.patch | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch

diff --git a/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch b/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
new file mode 100644
index 0000000000..39706048f3
--- /dev/null
+++ b/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
@@ -0,0 +1,50 @@
+From 9dbf27180c5ae04b11076c46da029bfd1446782a Mon Sep 17 00:00:00 2001
+From: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
+Date: Mon, 1 Jan 2024 22:04:15 +0200
+Subject: [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code
+ detected -- cannot go further'
+
+Forcing HAPROXY_CFLAGS on the haproxy build command line overrides CFLAGS
+which were internally set by the package Makefile.
+
+In such a way, a bunch of flags that were deduced by the package build script
+in *_CFLAGS variables, specifically in SPEC_CFLAGS, are omitted. Compiling and
+running haproxy without SPEC_CFLAGS taken into account results in runtime error:
+
+$ haproxy
+FATAL ERROR: invalid code detected -- cannot go further, please recompile!
+The source code was miscompiled by the compiler, which usually indicates that
+some of the CFLAGS needed to work around overzealous compiler optimizations
+were overwritten at build time. Please do not force CFLAGS, and read Makefile
+and INSTALL files to decide on the best way to pass your local build options.
+...
+
+This error is produced by haproxy.c [1] source which effectively ensures that INT_MAX+1
+expression wraps around using twos-complement representation. It is only true when -fwrapv
+gcc option is set in SPEC_CFLAGS.
+
+To address this, append necessary *_CFLAGS variables to the CFLAGS in haproxy Makefile.
+
+[1] https://git.haproxy.org/?p=haproxy.git;a=blob;f=src/haproxy.c;h=e1863255422459e806f7e50828e81976bb41c14c;hb=HEAD#l3304
+
+Signed-off-by: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index a66c9b69c..95fbb8a9c 100644
+--- a/Makefile
++++ b/Makefile
+@@ -289,7 +289,7 @@ ARCH_FLAGS        = $(ARCH_FLAGS.$(ARCH))
+ # These CFLAGS contain general optimization options, CPU-specific optimizations
+ # and debug flags. They may be overridden by some distributions which prefer to
+ # set all of them at once instead of playing with the CPU and DEBUG variables.
+-CFLAGS = $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS)
++override CFLAGS += $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS)
+ 
+ #### Common LDFLAGS
+ # These LDFLAGS are used as the first "ld" options, regardless of any library
+-- 
+2.39.2
+
-- 
2.39.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code detected -- cannot go further'
  2024-01-01 21:34 [Buildroot] [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code detected -- cannot go further' Aleksandr Makarov
@ 2024-01-13 21:13 ` Peter Korsgaard
  2024-01-17 18:02   ` Александр Макаров
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Korsgaard @ 2024-01-13 21:13 UTC (permalink / raw)
  To: Aleksandr Makarov; +Cc: buildroot

>>>>> "Aleksandr" == Aleksandr Makarov <aleksandr.o.makarov@gmail.com> writes:

 > Forcing HAPROXY_CFLAGS on the haproxy build command line overrides CFLAGS
 > which were internally set by the package Makefile.

 > In such a way, a bunch of flags that were deduced by the package build script
 > in *_CFLAGS variables, specifically in SPEC_CFLAGS, are omitted. Compiling and
 > running haproxy without SPEC_CFLAGS taken into account results in runtime error:

 > $ haproxy
 > FATAL ERROR: invalid code detected -- cannot go further, please recompile!
 > The source code was miscompiled by the compiler, which usually indicates that
 > some of the CFLAGS needed to work around overzealous compiler optimizations
 > were overwritten at build time. Please do not force CFLAGS, and read Makefile
 > and INSTALL files to decide on the best way to pass your local build options.
 > ...

 > This error is produced by haproxy.c [1] source which effectively ensures that INT_MAX+1
 > expression wraps around using twos-complement representation. It is only true when -fwrapv
 > gcc option is set in SPEC_CFLAGS.

 > To address this, append necessary *_CFLAGS variables to the CFLAGS in haproxy Makefile.

 > [1] https://git.haproxy.org/?p=haproxy.git;a=blob;f=src/haproxy.c;h=e1863255422459e806f7e50828e81976bb41c14c;hb=HEAD#l3304

 > Signed-off-by: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
 > ---
 >  ...fix-runtime-FATAL-ERROR-invalid-code.patch | 50 +++++++++++++++++++
 >  1 file changed, 50 insertions(+)
 >  create mode 100644 package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch

 > diff --git a/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch b/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
 > new file mode 100644
 > index 0000000000..39706048f3
 > --- /dev/null
 > +++ b/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
 > @@ -0,0 +1,50 @@
 > +From 9dbf27180c5ae04b11076c46da029bfd1446782a Mon Sep 17 00:00:00 2001
 > +From: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
 > +Date: Mon, 1 Jan 2024 22:04:15 +0200
 > +Subject: [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code
 > + detected -- cannot go further'

Has this patch been submitted upstream? If so, what is the status of it?

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code detected -- cannot go further'
  2024-01-13 21:13 ` Peter Korsgaard
@ 2024-01-17 18:02   ` Александр Макаров
  0 siblings, 0 replies; 3+ messages in thread
From: Александр Макаров @ 2024-01-17 18:02 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: buildroot

Rejected by upstream.

https://www.mail-archive.com/haproxy@formilux.org/msg44499.html

сб, 13 янв. 2024 г. в 23:13, Peter Korsgaard <peter@korsgaard.com>:
>
> >>>>> "Aleksandr" == Aleksandr Makarov <aleksandr.o.makarov@gmail.com> writes:
>
>  > Forcing HAPROXY_CFLAGS on the haproxy build command line overrides CFLAGS
>  > which were internally set by the package Makefile.
>
>  > In such a way, a bunch of flags that were deduced by the package build script
>  > in *_CFLAGS variables, specifically in SPEC_CFLAGS, are omitted. Compiling and
>  > running haproxy without SPEC_CFLAGS taken into account results in runtime error:
>
>  > $ haproxy
>  > FATAL ERROR: invalid code detected -- cannot go further, please recompile!
>  > The source code was miscompiled by the compiler, which usually indicates that
>  > some of the CFLAGS needed to work around overzealous compiler optimizations
>  > were overwritten at build time. Please do not force CFLAGS, and read Makefile
>  > and INSTALL files to decide on the best way to pass your local build options.
>  > ...
>
>  > This error is produced by haproxy.c [1] source which effectively ensures that INT_MAX+1
>  > expression wraps around using twos-complement representation. It is only true when -fwrapv
>  > gcc option is set in SPEC_CFLAGS.
>
>  > To address this, append necessary *_CFLAGS variables to the CFLAGS in haproxy Makefile.
>
>  > [1] https://git.haproxy.org/?p=haproxy.git;a=blob;f=src/haproxy.c;h=e1863255422459e806f7e50828e81976bb41c14c;hb=HEAD#l3304
>
>  > Signed-off-by: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
>  > ---
>  >  ...fix-runtime-FATAL-ERROR-invalid-code.patch | 50 +++++++++++++++++++
>  >  1 file changed, 50 insertions(+)
>  >  create mode 100644 package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
>
>  > diff --git a/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch b/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
>  > new file mode 100644
>  > index 0000000000..39706048f3
>  > --- /dev/null
>  > +++ b/package/haproxy/0002-package-haproxy-fix-runtime-FATAL-ERROR-invalid-code.patch
>  > @@ -0,0 +1,50 @@
>  > +From 9dbf27180c5ae04b11076c46da029bfd1446782a Mon Sep 17 00:00:00 2001
>  > +From: Aleksandr Makarov <aleksandr.o.makarov@gmail.com>
>  > +Date: Mon, 1 Jan 2024 22:04:15 +0200
>  > +Subject: [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code
>  > + detected -- cannot go further'
>
> Has this patch been submitted upstream? If so, what is the status of it?
>
> --
> Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2024-01-17 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-01 21:34 [Buildroot] [PATCH 1/1] package/haproxy: fix runtime 'FATAL ERROR: invalid code detected -- cannot go further' Aleksandr Makarov
2024-01-13 21:13 ` Peter Korsgaard
2024-01-17 18:02   ` Александр Макаров

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