avr-gcc@5 is broken

  • Done
  • quality assurance status badge
Details
4 participants
  • Arun Isaac
  • Danny Milosavljevic
  • Thompson, David
  • Efraim Flashner
Owner
unassigned
Submitted by
Thompson, David
Severity
normal

Debbugs page

Thompson, David wrote 8 years ago
(address . bug-guix@gnu.org)
CAJ=RwfbF+75d=E+mZ-_nNoHnRYL7Uy8m=CsQRGTwLi6jDQ-b4w@mail.gmail.com
avr-gcc cannot find device-specific libraries when compiling, which
from my reading is due to a problem with multilib. However, avr-gcc@4
works fine!

avr-gcc -O2 -DF_CPU=16000000UL -mmcu=atmega32u4 test.c -o test
avr-ld: cannot find -lm
avr-ld: cannot find -lc
avr-ld: cannot find -latmega32u4
collect2: error: ld returned 1 exit status

The libraries in question here are located within
/gnu/store/...-avr-libc-2.0.0/avr/lib/avr5 but avr-gcc is only
searching within /avr/lib.

For now, I'm just using avr-gcc@4 and moving on with life.

- Dave
Danny Milosavljevic wrote 8 years ago
(name . Thompson, David)(address . dthompson2@worcester.edu)(address . 24416@debbugs.gnu.org)
20160912084936.25713732@scratchpost.org
As a workaround,

CPPFLAGS += -I${HOME}/.guix-profile/avr/include
LDFLAGS += -L${HOME}/.guix-profile/avr/lib/avr5 -L${HOME}/.guix-profile/avr/lib -B${HOME}/.guix-profile/avr/lib

works with avr-gcc 5.3.0. Unfortunately I don't know enough about avr-gcc to be able to permanently fix it.

I fixed part of it (I made it so that atmega32u4 exists in the first place) in master - but no idea what to do with the search path.

I'm pretty sure that if it uses CROSS_CPATH it's incorrect because cross-base has been changed from CROSS_CPATH to CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH etc in order to suppress warnings. If CROSS_C_INCLUDE_PATH overrides CROSS_CPATH (does it?) then setting CROSS_CPATH like avr.scm does does no good.

I propose to change it to the following:

Toggle diff (25 lines)
diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index 9873477..1e5fd73 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -59,9 +59,18 @@
#t))))
((#:configure-flags flags)
`(delete "--disable-multilib" ,flags))))
- (native-search-paths
+ (native-search-paths
(list (search-path-specification
- (variable "CROSS_CPATH")
+ (variable "CROSS_C_INCLUDE_PATH")
+ (files '("avr/include")))
+ (search-path-specification
+ (variable "CROSS_CPLUS_INCLUDE_PATH")
+ (files '("avr/include")))
+ (search-path-specification
+ (variable "CROSS_OBJC_INCLUDE_PATH")
+ (files '("avr/include")))
+ (search-path-specification
+ (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
(files '("avr/include")))
(search-path-specification
(variable "CROSS_LIBRARY_PATH")
Thompson, David wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 24416@debbugs.gnu.org)
CAJ=RwfbNiMfy7CCFT_qJDrT-Reci7DSXmBSODaT96ofGtwrMTg@mail.gmail.com
On Mon, Sep 12, 2016 at 2:49 AM, Danny Milosavljevic
<dannym@scratchpost.org> wrote:
Toggle quote (39 lines)
> As a workaround,
>
> CPPFLAGS += -I${HOME}/.guix-profile/avr/include
> LDFLAGS += -L${HOME}/.guix-profile/avr/lib/avr5 -L${HOME}/.guix-profile/avr/lib -B${HOME}/.guix-profile/avr/lib
>
> works with avr-gcc 5.3.0. Unfortunately I don't know enough about avr-gcc to be able to permanently fix it.
>
> I fixed part of it (I made it so that atmega32u4 exists in the first place) in master - but no idea what to do with the search path.
>
> I'm pretty sure that if it uses CROSS_CPATH it's incorrect because cross-base has been changed from CROSS_CPATH to CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH etc in order to suppress warnings. If CROSS_C_INCLUDE_PATH overrides CROSS_CPATH (does it?) then setting CROSS_CPATH like avr.scm does does no good.
>
> I propose to change it to the following:
>
> diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
> index 9873477..1e5fd73 100644
> --- a/gnu/packages/avr.scm
> +++ b/gnu/packages/avr.scm
> @@ -59,9 +59,18 @@
> #t))))
> ((#:configure-flags flags)
> `(delete "--disable-multilib" ,flags))))
> - (native-search-paths
> + (native-search-paths
> (list (search-path-specification
> - (variable "CROSS_CPATH")
> + (variable "CROSS_C_INCLUDE_PATH")
> + (files '("avr/include")))
> + (search-path-specification
> + (variable "CROSS_CPLUS_INCLUDE_PATH")
> + (files '("avr/include")))
> + (search-path-specification
> + (variable "CROSS_OBJC_INCLUDE_PATH")
> + (files '("avr/include")))
> + (search-path-specification
> + (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
> (files '("avr/include")))
> (search-path-specification
> (variable "CROSS_LIBRARY_PATH")

I don't know if this will have the intended effect and I cannot
experiment with it right now. Could you test? The LDFLAGS above
include the path to the device-specific object files (/avr5), but
avr-gcc is supposed to be able to figure that out on its own using a
"normal" library path, so I'm skeptical that simply changing the
search paths for the package is enough.

Thanks,

- Dave
Danny Milosavljevic wrote 8 years ago
(name . Thompson, David)(address . dthompson2@worcester.edu)(address . 24416@debbugs.gnu.org)
20160913111822.3da1c609@scratchpost.org
On Mon, 12 Sep 2016 11:29:11 -0400
"Thompson, David" <dthompson2@worcester.edu> wrote:

Toggle quote (44 lines)
> On Mon, Sep 12, 2016 at 2:49 AM, Danny Milosavljevic
> <dannym@scratchpost.org> wrote:
> > As a workaround,
> >
> > CPPFLAGS += -I${HOME}/.guix-profile/avr/include
> > LDFLAGS += -L${HOME}/.guix-profile/avr/lib/avr5 -L${HOME}/.guix-profile/avr/lib -B${HOME}/.guix-profile/avr/lib
> >
> > works with avr-gcc 5.3.0. Unfortunately I don't know enough about avr-gcc to be able to permanently fix it.
> >
> > I fixed part of it (I made it so that atmega32u4 exists in the first place) in master - but no idea what to do with the search path.
> >
> > I'm pretty sure that if it uses CROSS_CPATH it's incorrect because cross-base has been changed from CROSS_CPATH to CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH etc in order to suppress warnings. If CROSS_C_INCLUDE_PATH overrides CROSS_CPATH (does it?) then setting CROSS_CPATH like avr.scm does does no good.
> >
> > I propose to change it to the following:
> >
> > diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
> > index 9873477..1e5fd73 100644
> > --- a/gnu/packages/avr.scm
> > +++ b/gnu/packages/avr.scm
> > @@ -59,9 +59,18 @@
> > #t))))
> > ((#:configure-flags flags)
> > `(delete "--disable-multilib" ,flags))))
> > - (native-search-paths
> > + (native-search-paths
> > (list (search-path-specification
> > - (variable "CROSS_CPATH")
> > + (variable "CROSS_C_INCLUDE_PATH")
> > + (files '("avr/include")))
> > + (search-path-specification
> > + (variable "CROSS_CPLUS_INCLUDE_PATH")
> > + (files '("avr/include")))
> > + (search-path-specification
> > + (variable "CROSS_OBJC_INCLUDE_PATH")
> > + (files '("avr/include")))
> > + (search-path-specification
> > + (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
> > (files '("avr/include")))
> > (search-path-specification
> > (variable "CROSS_LIBRARY_PATH")
>
> I don't know if this will have the intended effect and I cannot
> experiment with it right now. Could you test?

(The patch: ) Can't test it right now (out of disk space; updating 2 GB texmf is really annoying) - but I tested it in the past and it wasn't sufficient. On the other hand, before the patch is applied, cross-gcc and avr.scm set *different* variables and that's probably incorrect.

Toggle quote (6 lines)
> The LDFLAGS above
> include the path to the device-specific object files (/avr5), but
> avr-gcc is supposed to be able to figure that out on its own using a
> "normal" library path, so I'm skeptical that simply changing the
> search paths for the package is enough.

I've used these LDFLAGS (actually used them as global flags for all gcc invocations) for some weeks with daily success. Also, the "-B" is necessary.

I think that the "native-search-paths" only affect the build system.

As far as I understand, avr-gcc is a "native" compiler in the sense of it-shouldn't-try-to-build-all-Guix-packages-for-it. And it's certainly set up as a "native" compiler. But that means that the avr-gcc port has to hack the search path that gcc usually uses for native compilers to make it search something else - not sure where they do and why it doesn't work for us. It would be good to locate this part.

The atmega32u4 comes from avr-libc (!) - that's why I changed avr-libc to use the same compiler (already in master for some months). That made it work much better.

I hope someone can shed a light on this.
Danny Milosavljevic wrote 7 years ago
[PATCH] gnu: avr-gcc: Fix compiler lookup paths.
(name . Thompson, David)(address . dthompson2@worcester.edu)(address . 24416@debbugs.gnu.org)
20171222154540.1444b5e6@scratchpost.org
* gnu/packages/avr.scm (avr-gcc-4.9): Use CROSS_C*_INCLUDE_PATH (like
cross-base does).
(avr-gcc-5)[source]: Apply patch "gcc-cross-environment-variables.patch".
---
gnu/packages/avr.scm | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

Toggle diff (34 lines)
diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index ecb7cd19a..60bcbe754 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -61,7 +61,16 @@
`(delete "--disable-multilib" ,flags))))
(native-search-paths
(list (search-path-specification
- (variable "CROSS_CPATH")
+ (variable "CROSS_C_INCLUDE_PATH")
+ (files '("avr/include")))
+ (search-path-specification
+ (variable "CROSS_CPLUS_INCLUDE_PATH")
+ (files '("avr/include")))
+ (search-path-specification
+ (variable "CROSS_OBJC_INCLUDE_PATH")
+ (files '("avr/include")))
+ (search-path-specification
+ (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
(files '("avr/include")))
(search-path-specification
(variable "CROSS_LIBRARY_PATH")
@@ -71,7 +80,10 @@
(package
(inherit avr-gcc-4.9)
(version (package-version gcc-5))
- (source (package-source gcc-5))))
+ (source (origin
+ (inherit (package-source gcc-5))
+ (patches (append (origin-patches (package-source gcc-5))
+ (search-patches "gcc-cross-environment-variables.patch")))))))
(define (avr-libc avr-gcc)
(package
Arun Isaac wrote 5 years ago
(address . 24416@debbugs.gnu.org)
cu7y2sk7f05.fsf@systemreboot.net
Toggle quote (4 lines)
> * gnu/packages/avr.scm (avr-gcc-4.9): Use CROSS_C*_INCLUDE_PATH (like
> cross-base does).
> (avr-gcc-5)[source]: Apply patch "gcc-cross-environment-variables.patch".

Hi,

I verified that this patch works[1]. Could you please push to master?

Thanks! :-)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAl5bWUsACgkQLiXui2GA
K7PqaQgAtwTDRUz3/YayC8uNVZQ4Zt8Ry1UZzHLhr0jqdctelMd67w33XSpfsYQC
Eip5kidZlyyrZoqebO14BdSGo+3TKRD7jKLyUAOH7w719o2Trhj6ZNaEagKhpkYE
RCc1DtP30TwjjXyN/Z6tseD3cQr7fC/g7HPBNRdhzI2sBCN5MnPYfezkr3KDx0Aa
qVc36In6LEvP4Pb+ZNzHzQqbHE12h6mZwAw8HU51TvfP3R1ERsY3WxFRiqGUqmRn
78okoh/5Oxg7w6HznDW5OIsrFWaWt601dfZjzkbcqFFeGZFbjq7XlkgwspSrG1F9
02sjv5sXrwOF/fGmbD8UuQX9fqOhBA==
=fpqj
-----END PGP SIGNATURE-----

Danny Milosavljevic wrote 5 years ago
(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20200301132531.788a495e@scratchpost.org
Hi Arun,

pushed to guix master as commit 2f3515f7369d91d8922620044f9348cc727b6c10.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl5bqbsACgkQ5xo1VCww
uqUK2gf+KquLoQ59HL49mdkystSy213oyuWwVDi/oMdBoonggjjpFFTTdgq7TE9y
dYVTVe2/SECsxvXUDNzlRKfHcvJT0ftHvYvtGtGXr8Op3lK5iZs7Kiy2fOxkAYQh
bjNP+g1yVX86UsqKEhPZt3M0fDc0zxUdbKX2mbUWdCyDGq6j/GZhz3aumdALm5Ci
3QyY2AhSvfplqV7GzZFykXKfAIxp2NlfsOH5IHpbIjfTQamqsBjM1COfgRoww7jo
J+5Kc1FsIGf8HIlIYcuJbTR7qVNIEfuRi/BmnB+Wz+6+eTgvlK4VHCUwTXY73T63
VaudlNK+rmcEVSpsnxyzkhjSlpmhVA==
=LzBy
-----END PGP SIGNATURE-----


Efraim Flashner wrote 5 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20200513192812.GJ918@E5400
Closing this bug as fixed.


--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl68SkkACgkQQarn3Mo9
g1F6Ew/+NGj3Nsb4pbscHQM77kVvlmBjnE1btKOQIU46WCcr4FFQKQY0s06/DZlW
xEWIOi//WyOVe+p4TC6bLm7WogR/eTFYV6qD4uwQQUFIebDA61V49z/gTnoFMb36
L786QGplnPTK10/d0YuTEyJjapOGe9tdBAORp+xlszCMZIu6YKj8yZYsNlb5vD48
ogzONMf1NgQNrD7y/PwRO+H3Mqqo2x5Mb3/wfecmdsnccL13yInzsLRyhEXvxTDv
cpmEPX97IDQqIoNRhXdUnAJcxgB3Knym52dxZFaNMhTsiVLv3GynAeErRE0TcJEZ
TBPSSnlL2OBeoDKQ2W144D8SEhoa4/p+4UE/Uu1Qrh4aJYnqjUcFBIHmpiGH3h7Q
I4da+rBuYD7tH4nCAPH0PngDVS5FV8cKdbpfe0C1Ia+iRok455BC2xvst3qBzbcw
4UzSsJL7x/RkOC0xZA8QCprdQcX7jdFnUs7GZOJUd8kfEOzmfcVu851qVtNMXhGg
MJKA1XtLKq3z2ITVtW82oANVexIZBuezaJxZToHydW2O51u8IHieDh/Z8tEftRw0
/Uk3kw5eBPTnGR2hUtVCwoqlJVNCamPtfx75ASK5WDGjBth50VFQeGZ6pfuBIIcb
S8Wjp7QVYnfMmxylomLlzQLN3DPm6Jv+Z4ZN0MHKaiuB8wM234o=
=GmQb
-----END PGP SIGNATURE-----


Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 24416@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 24416
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help