mxe icon indicating copy to clipboard operation
mxe copied to clipboard

Failed to build gcc 8/10/11 for 64bit: "error: implicit declaration of function 'getpagesize'" (missing mmap)

Open kmatheussen opened this issue 2 years ago • 5 comments

/home/kjetil/mxe/tmp-gcc-x86_64-w64-mingw32.shared/gcc-11.2.0/libbacktrace/mmapio.c: In function 'backtrace_get_view':
/home/kjetil/mxe/tmp-gcc-x86_64-w64-mingw32.shared/gcc-11.2.0/libbacktrace/mmapio.c:73:14: error: implicit declaration of function 'getpagesize' [-Werror=implicit-function-declaration]
   73 |   pagesize = getpagesize ();
      |              ^~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:1401: recipe for target 'mmapio.lo' failed

This patch might fix it: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=47f4703c33c4936fd423c2a1180b2de144115d3d I tried to apply it, but it didn't apply cleanly, so I'm not sure if it'll work.

gcc_x86_64-w64-mingw32.shared.gz

kmatheussen avatar Apr 11 '22 14:04 kmatheussen

Same error when trying to compile gcc10. It's not happening for i686.

kmatheussen avatar Apr 11 '22 15:04 kmatheussen

Same error with gcc8 as well. That's strange because I've compiled gcc8 successfully before.

kmatheussen avatar Apr 11 '22 16:04 kmatheussen

First I fixed the missing 'getpagesize' definition, but then I got linker errors about missing 'mmap' and 'munmap' functions. Seems like the configuration has started thinking that I have mmap. So as a workaround I force-patched libbacktrace/configure not to use mmap (see below). Don't know what the proper fix is...

--- a/libbacktrace/configure~	2020-03-04 09:32:13.000000000 +0100
+++ b/libbacktrace/configure	2022-04-11 20:18:49.425544396 +0200
@@ -12614,51 +12614,8 @@
 
 done
 
-if test "$ac_cv_header_sys_mman_h" = "no"; then
-  have_mmap=no
-else
-  if test -n "${with_target_subdir}"; then
-    # When built as a GCC target library, we can't do a link test.  We
-    # simply assume that if we have mman.h, we have mmap.
-    have_mmap=yes
-    case "${host}" in
-    spu-*-*|*-*-msdosdjgpp)
-        # The SPU does not have mmap, but it has a sys/mman.h header file
-        # containing "mmap_eaddr" and the mmap flags, confusing the test.
-        # DJGPP also has sys/man.h, but no mmap
-	have_mmap=no ;;
-    esac
-  else
-    ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
-if test "x$ac_cv_func_mmap" = x""yes; then :
-  have_mmap=yes
-else
-  have_mmap=no
-fi
-
-  fi
-fi
-if test "$have_mmap" = "no"; then
-  VIEW_FILE=read.lo
-  ALLOC_FILE=alloc.lo
-else
-  VIEW_FILE=mmapio.lo
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <sys/mman.h>
-#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
-  #error no MAP_ANONYMOUS
-#endif
-
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ALLOC_FILE=mmap.lo
-else
-  ALLOC_FILE=alloc.lo
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
+VIEW_FILE=read.lo
+ALLOC_FILE=alloc.lo

kmatheussen avatar Apr 11 '22 18:04 kmatheussen

Are you rebuilding gcc after mman-win32 is installed? These might be similar issues #2526 #2529.

I think you can try:

make gcc gcc_CONFIGURE_OPTS=ac_cv_header_sys_mman_h=no

or adding a line to remove sys/mman.h here https://github.com/mxe/mxe/blob/master/src/gcc.mk#L66.

tonytheodore avatar Apr 11 '22 23:04 tonytheodore

Yes, mman-win32 seems to have been installed after gcc was originally installed:

@.***:~/mxe$ ls -la ./log/20201222_170347/mman-win32_x86_64-w64-mingw32.shared -rw-rw-r-- 1 kjetil kjetil 36999 des. 22 2020 ./log/20201222_170347/mman-win32_x86_64-w64-mingw32.shared

I haven't installed it manually so I guess it must have been pulled in as a dependency for something.

Now I was upgrading the qt5 package (after doing "git pull"), and then it also wanted to upgrade, or perhaps recompile, gcc.

On Tue, Apr 12, 2022 at 1:28 AM Tony Theodore @.***> wrote:

Are you rebuilding gcc after mman-win32 is installed? These might be similar issues #2526 https://github.com/mxe/mxe/issues/2526 #2529 https://github.com/mxe/mxe/issues/2529.

I think you can try:

make gcc gcc_CONFIGURE_OPTS=ac_cv_header_sys_mman_h=no

or adding a line to remove sys/mman.h here https://github.com/mxe/mxe/blob/master/src/gcc.mk#L66.

— Reply to this email directly, view it on GitHub https://github.com/mxe/mxe/issues/2813#issuecomment-1095690048, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIX3JYKSZZHQ7WY2Y24Y7DVESYTBANCNFSM5TDMME5A . You are receiving this because you authored the thread.Message ID: @.***>

kmatheussen avatar Apr 12 '22 07:04 kmatheussen