unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37509: [core-updates] [PATCH] gnu: gcc: Fix mingw cross compiler.
@ 2019-09-24 18:34 Jan Nieuwenhuizen
  2019-09-25  5:06 ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2019-09-24 18:34 UTC (permalink / raw)
  To: 37509

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Running

    ./pre-inst-env guix build --target=x86_64-w64-mingw32 hello

on core-updates fails with

--8<---------------cut here---------------start------------->8---
../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc: In function ‘void* __gnu_cxx::aligned_alloc(std::size_t, std::size_t)’:
../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc:78:10: error: ‘memalign’ was not declared in this scope
   return memalign (al, sz);
          ^~~~~~~~
../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc:78:10: note: suggested alternative: ‘max_align_t’
   return memalign (al, sz);
          ^~~~~~~~
          max_align_t
--8<---------------cut here---------------end--------------->8---

The attached patch fixes this and produces a working cross-built hello.

The weird thing is that I looked at Debian's mingw cross compilers and
its mingw-w64 package and cannot seem to find anything that resembles
this build problem or a fix.

Greetings,
janneke


[-- Attachment #2: 0001-gnu-gcc-Fix-mingw-cross-compiler.patch --]
[-- Type: text/x-patch, Size: 3489 bytes --]

From 4966d8dc9e079a5fb776f456dfb3f0918bcfa1b9 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 24 Sep 2019 20:23:31 +0200
Subject: [PATCH] gnu: gcc: Fix mingw cross compiler.

* gnu/packages/patches/gcc-7-cross-mingw.patch: New file.
* gnu/packages/cross-base.scm (cross-gcc): Use it for target mingw and gcc >= 7.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                 |  1 +
 gnu/packages/cross-base.scm                  |  6 ++++-
 gnu/packages/patches/gcc-7-cross-mingw.patch | 24 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/gcc-7-cross-mingw.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 5705494090..a7b1c65e82 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -851,6 +851,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gcc-6-cross-environment-variables.patch	\
   %D%/packages/patches/gcc-6-source-date-epoch-1.patch		\
   %D%/packages/patches/gcc-6-source-date-epoch-2.patch		\
+  %D%/packages/patches/gcc-7-cross-mingw.patch			\
   %D%/packages/patches/gcc-8-cross-environment-variables.patch	\
   %D%/packages/patches/gcc-8-strmov-store-file-names.patch	\
   %D%/packages/patches/gcc-9-asan-fix-limits-include.patch	\
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 78dae7431a..36f2f5961f 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -229,7 +229,11 @@ target that libc."
                        ((version>=? (package-version xgcc) "8.0") (search-patch "gcc-8-cross-environment-variables.patch"))
                        ((version>=? (package-version xgcc) "6.0") (search-patch "gcc-6-cross-environment-variables.patch"))
                        (else  (search-patch "gcc-cross-environment-variables.patch")))
-                      (cross-gcc-patches target))))
+                      (cross-gcc-patches target))
+                (if (and (target-mingw? target)
+                         (version>=? (package-version xgcc) "7.0"))
+                    (search-patches "gcc-7-cross-mingw.patch")
+                    '())))
               (modules '((guix build utils)))
               (snippet
                (cross-gcc-snippet target))))
diff --git a/gnu/packages/patches/gcc-7-cross-mingw.patch b/gnu/packages/patches/gcc-7-cross-mingw.patch
new file mode 100644
index 0000000000..eec6f88953
--- /dev/null
+++ b/gnu/packages/patches/gcc-7-cross-mingw.patch
@@ -0,0 +1,24 @@
+This fixes
+
+../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc: In function ‘void* __gnu_cxx::aligned_alloc(std::size_t, std::size_t)’:
+../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc:78:10: error: ‘memalign’ was not declared in this scope
+   return memalign (al, sz);
+          ^~~~~~~~
+../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc:78:10: note: suggested alternative: ‘max_align_t’
+   return memalign (al, sz);
+          ^~~~~~~~
+          max_align_t
+
+diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc
+index 94e79cadb0e..084900e0daf 100644
+--- a/libstdc++-v3/libsupc++/new_opa.cc
++++ b/libstdc++-v3/libsupc++/new_opa.cc
+@@ -39,6 +39,8 @@ extern "C" void *memalign(std::size_t boundary, std::size_t size);
+ # endif
+ #endif
+ 
++#define memalign _aligned_malloc
++
+ using std::new_handler;
+ using std::bad_alloc;
+ 
-- 
2.23.0


[-- Attachment #3: Type: text/plain, Size: 154 bytes --]



-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

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

* bug#37509: [core-updates] [PATCH] gnu: gcc: Fix mingw cross compiler.
  2019-09-24 18:34 bug#37509: [core-updates] [PATCH] gnu: gcc: Fix mingw cross compiler Jan Nieuwenhuizen
@ 2019-09-25  5:06 ` Jan Nieuwenhuizen
  2019-09-26 20:02   ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2019-09-25  5:06 UTC (permalink / raw)
  To: 37509

[-- Attachment #1: Type: text/plain, Size: 114 bytes --]

Jan Nieuwenhuizen writes:

I sent it as when it worked and then found it could be cleaned up; attached.

janneke


[-- Attachment #2: 0001-gnu-gcc-Fix-mingw-cross-compiler.patch --]
[-- Type: text/x-patch, Size: 4851 bytes --]

From 051e4a62cbc6d48015f0f2f807141ad92ac73cf2 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 24 Sep 2019 20:23:31 +0200
Subject: [PATCH] gnu: gcc: Fix mingw cross compiler.

* gnu/packages/patches/gcc-7-cross-mingw.patch: New file.
* gnu/packages/cross-base.scm (cross-gcc-patches): Add XGCC parameter; update
caller.  Use it for target mingw and gcc >= 7.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                 |  1 +
 gnu/packages/cross-base.scm                  | 13 +++++++----
 gnu/packages/patches/gcc-7-cross-mingw.patch | 24 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 5 deletions(-)
 create mode 100644 gnu/packages/patches/gcc-7-cross-mingw.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 5705494090..a7b1c65e82 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -851,6 +851,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gcc-6-cross-environment-variables.patch	\
   %D%/packages/patches/gcc-6-source-date-epoch-1.patch		\
   %D%/packages/patches/gcc-6-source-date-epoch-2.patch		\
+  %D%/packages/patches/gcc-7-cross-mingw.patch			\
   %D%/packages/patches/gcc-8-cross-environment-variables.patch	\
   %D%/packages/patches/gcc-8-strmov-store-file-names.patch	\
   %D%/packages/patches/gcc-9-asan-fix-limits-include.patch	\
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 78dae7431a..6b27c3cff7 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016, 2019 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
@@ -190,13 +190,16 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                               '("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH")))
                   #t))))))))))
 
-(define (cross-gcc-patches target)
-  "Return GCC patches needed for TARGET."
+(define (cross-gcc-patches xgcc target)
+  "Return GCC patches needed for XGCC and TARGET."
   (cond ((string-prefix? "xtensa-" target)
          ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
          (search-patches "ath9k-htc-firmware-gcc.patch"))
         ((target-mingw? target)
-         (search-patches "gcc-4.9.3-mingw-gthr-default.patch"))
+         (append (search-patches "gcc-4.9.3-mingw-gthr-default.patch")
+                 (if (version>=? (package-version xgcc) "7.0")
+                     (search-patches "gcc-7-cross-mingw.patch")
+                    '())))
         (else '())))
 
 (define (cross-gcc-snippet target)
@@ -229,7 +232,7 @@ target that libc."
                        ((version>=? (package-version xgcc) "8.0") (search-patch "gcc-8-cross-environment-variables.patch"))
                        ((version>=? (package-version xgcc) "6.0") (search-patch "gcc-6-cross-environment-variables.patch"))
                        (else  (search-patch "gcc-cross-environment-variables.patch")))
-                      (cross-gcc-patches target))))
+                      (cross-gcc-patches xgcc target))))
               (modules '((guix build utils)))
               (snippet
                (cross-gcc-snippet target))))
diff --git a/gnu/packages/patches/gcc-7-cross-mingw.patch b/gnu/packages/patches/gcc-7-cross-mingw.patch
new file mode 100644
index 0000000000..eec6f88953
--- /dev/null
+++ b/gnu/packages/patches/gcc-7-cross-mingw.patch
@@ -0,0 +1,24 @@
+This fixes
+
+../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc: In function ‘void* __gnu_cxx::aligned_alloc(std::size_t, std::size_t)’:
+../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc:78:10: error: ‘memalign’ was not declared in this scope
+   return memalign (al, sz);
+          ^~~~~~~~
+../../../../gcc-7.4.0/libstdc++-v3/libsupc++/new_opa.cc:78:10: note: suggested alternative: ‘max_align_t’
+   return memalign (al, sz);
+          ^~~~~~~~
+          max_align_t
+
+diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc
+index 94e79cadb0e..084900e0daf 100644
+--- a/libstdc++-v3/libsupc++/new_opa.cc
++++ b/libstdc++-v3/libsupc++/new_opa.cc
+@@ -39,6 +39,8 @@ extern "C" void *memalign(std::size_t boundary, std::size_t size);
+ # endif
+ #endif
+ 
++#define memalign _aligned_malloc
++
+ using std::new_handler;
+ using std::bad_alloc;
+ 
-- 
2.23.0


[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

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

* bug#37509: [core-updates] [PATCH] gnu: gcc: Fix mingw cross compiler.
  2019-09-25  5:06 ` Jan Nieuwenhuizen
@ 2019-09-26 20:02   ` Ludovic Courtès
  2019-09-27  5:24     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2019-09-26 20:02 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: 37509

Hello,

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

>From 051e4a62cbc6d48015f0f2f807141ad92ac73cf2 Mon Sep 17 00:00:00 2001
> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Tue, 24 Sep 2019 20:23:31 +0200
> Subject: [PATCH] gnu: gcc: Fix mingw cross compiler.
>
> * gnu/packages/patches/gcc-7-cross-mingw.patch: New file.
> * gnu/packages/cross-base.scm (cross-gcc-patches): Add XGCC parameter; update
> caller.  Use it for target mingw and gcc >= 7.
> * gnu/local.mk (dist_patch_DATA): Add it.

LGTM!  Glad you found out how to fix it.

Thanks,
Ludo’.

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

* bug#37509: [core-updates] [PATCH] gnu: gcc: Fix mingw cross compiler.
  2019-09-26 20:02   ` Ludovic Courtès
@ 2019-09-27  5:24     ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2019-09-27  5:24 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 37509-done

Ludovic Courtès writes:

Hello,

> LGTM!  Glad you found out how to fix it.

Thanks, yes.  I'm not all too happy that I cannot find others having
trouble with this, let alone creating a bug report for either gcc or
mingw-w64.  Oh well...

Pushed to core-updates as 308eb5c11a885768f81fb6136fd4d30b4639fe04

Greetings,
janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

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

end of thread, other threads:[~2019-09-27  5:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 18:34 bug#37509: [core-updates] [PATCH] gnu: gcc: Fix mingw cross compiler Jan Nieuwenhuizen
2019-09-25  5:06 ` Jan Nieuwenhuizen
2019-09-26 20:02   ` Ludovic Courtès
2019-09-27  5:24     ` Jan Nieuwenhuizen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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