host-x86_64-pc-linux-gnu/gcc/xgcc: No such file or directory

2023-11-29 Thread Jonny Grant
Hello

Has anyone encountered this when compiling gcc from source? libgomp doesn't 
build due to xgcc missing

I got latest git, did
./configure --disable-multilib
make html

It gets stuck here:

checking whether make supports nested variables... yes
/home/jonny/code/repos/gcc_tests/gcc_doc/libgomp/configure: line 3520: 
/home/jonny/code/repos/gcc_tests/gcc_doc/host-x86_64-pc-linux-gnu/gcc/xgcc: No 
such file or directory
checking for x86_64-pc-linux-gnu-gcc... 
/home/jonny/code/repos/gcc_tests/gcc_doc/host-x86_64-pc-linux-gnu/gcc/xgcc 
-B/home/jonny/code/repos/gcc_tests/gcc_doc/host-x86_64-pc-linux-gnu/gcc/ 
-B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ 
-isystem /usr/local/x86_64-pc-linux-gnu/include -isystem 
/usr/local/x86_64-pc-linux-gnu/sys-include   
checking whether the C compiler works... no
configure: error: in 
`/home/jonny/code/repos/gcc_tests/gcc_doc/x86_64-pc-linux-gnu/libgomp':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** [Makefile:23679: configure-target-libgomp] Error 1
make[1]: Leaving directory '/home/jonny/code/repos/gcc_tests/gcc_doc'
make: *** [Makefile:1456: do-html] Error 2


I tried with:
./configure --disable-multilib --disable-libgomp

but it just stops at the next 

checking for x86_64-pc-linux-gnu-gcc... 
/home/jonny/code/repos/gcc_tests/gcc_doc/host-x86_64-pc-linux-gnu/gcc/xgcc 
-B/home/jonny/code/repos/gcc_tests/gcc_doc/host-x86_64-pc-linux-gnu/gcc/ 
-B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ 
-isystem /usr/local/x86_64-pc-linux-gnu/include -isystem 
/usr/local/x86_64-pc-linux-gnu/sys-include   
checking for suffix of object files... configure: error: in 
`/home/jonny/code/repos/gcc_tests/gcc_doc/x86_64-pc-linux-gnu/libstdc++-v3':
configure: error: cannot compute suffix of object files: cannot compile
ee `config.log' for more details
make[1]: *** [Makefile:17042: configure-target-libstdc++-v3] Error 1


Thanks, Jonny


Re: host-x86_64-pc-linux-gnu/gcc/xgcc: No such file or directory

2023-11-29 Thread Jonathan Wakely via Gcc
On Wed, 29 Nov 2023 at 12:59, Jonny Grant  wrote:
>
> Hello
>
> Has anyone encountered this when compiling gcc from source? libgomp doesn't 
> build due to xgcc missing
>
> I got latest git, did
> ./configure --disable-multilib

Don't build in the source directory: https://gcc.gnu.org/wiki/FAQ#configure

> make html

Try make all-gcc before make html.


Re: host-x86_64-pc-linux-gnu/gcc/xgcc: No such file or directory

2023-11-29 Thread Jonny Grant



On 29/11/2023 13:05, Jonathan Wakely wrote:
> On Wed, 29 Nov 2023 at 12:59, Jonny Grant  wrote:
>>
>> Hello
>>
>> Has anyone encountered this when compiling gcc from source? libgomp doesn't 
>> build due to xgcc missing
>>
>> I got latest git, did
>> ./configure --disable-multilib
> 
> Don't build in the source directory: https://gcc.gnu.org/wiki/FAQ#configure
> 
>> make html
> 
> Try make all-gcc before make html.


Sure. 

It gets stuck on genmodes.cc



../gcc_doc/configure --prefix=/home/jonny/code/repos/gcc_tests/gcc_install 
--disable-multilib

$ make all-gcc

make[1]: Entering directory '/home/jonny/code/repos/gcc_tests/gcc_build/gcc'
g++ -std=c++11 -c   -g -O2   -DIN_GCC-fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Wconditionally-supported 
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros 
-Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H  -DGENERATOR_FILE -I. 
-Ibuild -I../../gcc_doc/gcc -I../../gcc_doc/gcc/build 
-I../../gcc_doc/gcc/../include  -I../../gcc_doc/gcc/../libcpp/include  \
-o build/genmodes.o ../../gcc_doc/gcc/genmodes.cc
In file included from ../../gcc_doc/gcc/bconfig.h:3,
 from ../../gcc_doc/gcc/genmodes.cc:20:
../../gcc_doc/gcc/auto-host.h:2717:16: error: declaration does not declare 
anything [-fpermissive]
 2717 | #define rlim_t long
  |^~~~
In file included from ../../gcc_doc/gcc/genmodes.cc:21:
../../gcc_doc/gcc/system.h:500:14: error: conflicting declaration of C function 
‘void* sbrk(int)’
  500 | extern void *sbrk (int);
  |  ^~~~
In file included from ../../gcc_doc/gcc/system.h:302:
/usr/include/unistd.h:1076:14: note: previous declaration ‘void* sbrk(intptr_t)’
 1076 | extern void *sbrk (intptr_t __delta) __THROW;
  |  ^~~~
../../gcc_doc/gcc/system.h:508:14: error: ambiguating new declaration of ‘char* 
strstr(const char*, const char*)’
  508 | extern char *strstr (const char *, const char *);
  |  ^~
In file included from /usr/include/c++/13/cstring:42,
 from ../../gcc_doc/gcc/system.h:241:
/usr/include/string.h:343:1: note: old declaration ‘const char* strstr(const 
char*, const char*)’
  343 | strstr (const char *__haystack, const char *__needle) __THROW
  | ^~
../../gcc_doc/gcc/system.h:556:20: error: conflicting declaration of C function 
‘const char* strsignal(int)’
  556 | extern const char *strsignal (int);
  |^
/usr/include/string.h:478:14: note: previous declaration ‘char* strsignal(int)’
  478 | extern char *strsignal (int __sig) __THROW;
  |  ^
In file included from ../../gcc_doc/gcc/system.h:729:
../../gcc_doc/gcc/../include/libiberty.h:112:14: error: ambiguating new 
declaration of ‘char* basename(const char*)’
  112 | extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL 
ATTRIBUTE_NONNULL(1);
  |  ^~~~
/usr/include/string.h:537:26: note: old declaration ‘const char* basename(const 
char*)’
  537 | extern "C++" const char *basename (const char *__filename)
  |  ^~~~
make[1]: *** [Makefile:2987: build/genmodes.o] Error 1
make[1]: Leaving directory '/home/jonny/code/repos/gcc_tests/gcc_build/gcc'
make: *** [Makefile:4996: all-gcc] Error 2


Kind regards, Jonny


Re: host-x86_64-pc-linux-gnu/gcc/xgcc: No such file or directory

2023-11-29 Thread Jonathan Wakely via Gcc
On Wed, 29 Nov 2023 at 14:44, Jonny Grant  wrote:
>
>
>
> On 29/11/2023 13:05, Jonathan Wakely wrote:
> > On Wed, 29 Nov 2023 at 12:59, Jonny Grant  wrote:
> >>
> >> Hello
> >>
> >> Has anyone encountered this when compiling gcc from source? libgomp 
> >> doesn't build due to xgcc missing
> >>
> >> I got latest git, did
> >> ./configure --disable-multilib
> >
> > Don't build in the source directory: https://gcc.gnu.org/wiki/FAQ#configure
> >
> >> make html
> >
> > Try make all-gcc before make html.
>
>
> Sure.
>
> It gets stuck on genmodes.cc
>
>
>
> ../gcc_doc/configure --prefix=/home/jonny/code/repos/gcc_tests/gcc_install 
> --disable-multilib

This belongs on the gcc-help list, not here.

Are you sure you ran configure in an empty dir, not one you'd already
fouled up with previous configurations or previous 'make html'
commands?
You should start in a completely empty directory. And I assume
../gcc_doc is not the same directory as .

The errors you're getting should not happen unless you've messed up
the configure step somehow.

>
> $ make all-gcc
> 
> make[1]: Entering directory '/home/jonny/code/repos/gcc_tests/gcc_build/gcc'
> g++ -std=c++11 -c   -g -O2   -DIN_GCC-fno-exceptions -fno-rtti 
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
> -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported 
> -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros 
> -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H  -DGENERATOR_FILE -I. 
> -Ibuild -I../../gcc_doc/gcc -I../../gcc_doc/gcc/build 
> -I../../gcc_doc/gcc/../include  -I../../gcc_doc/gcc/../libcpp/include  \
> -o build/genmodes.o ../../gcc_doc/gcc/genmodes.cc
> In file included from ../../gcc_doc/gcc/bconfig.h:3,
>  from ../../gcc_doc/gcc/genmodes.cc:20:
> ../../gcc_doc/gcc/auto-host.h:2717:16: error: declaration does not declare 
> anything [-fpermissive]
>  2717 | #define rlim_t long
>   |^~~~
> In file included from ../../gcc_doc/gcc/genmodes.cc:21:
> ../../gcc_doc/gcc/system.h:500:14: error: conflicting declaration of C 
> function ‘void* sbrk(int)’
>   500 | extern void *sbrk (int);
>   |  ^~~~
> In file included from ../../gcc_doc/gcc/system.h:302:
> /usr/include/unistd.h:1076:14: note: previous declaration ‘void* 
> sbrk(intptr_t)’
>  1076 | extern void *sbrk (intptr_t __delta) __THROW;
>   |  ^~~~
> ../../gcc_doc/gcc/system.h:508:14: error: ambiguating new declaration of 
> ‘char* strstr(const char*, const char*)’
>   508 | extern char *strstr (const char *, const char *);
>   |  ^~
> In file included from /usr/include/c++/13/cstring:42,
>  from ../../gcc_doc/gcc/system.h:241:
> /usr/include/string.h:343:1: note: old declaration ‘const char* strstr(const 
> char*, const char*)’
>   343 | strstr (const char *__haystack, const char *__needle) __THROW
>   | ^~
> ../../gcc_doc/gcc/system.h:556:20: error: conflicting declaration of C 
> function ‘const char* strsignal(int)’
>   556 | extern const char *strsignal (int);
>   |^
> /usr/include/string.h:478:14: note: previous declaration ‘char* 
> strsignal(int)’
>   478 | extern char *strsignal (int __sig) __THROW;
>   |  ^
> In file included from ../../gcc_doc/gcc/system.h:729:
> ../../gcc_doc/gcc/../include/libiberty.h:112:14: error: ambiguating new 
> declaration of ‘char* basename(const char*)’
>   112 | extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL 
> ATTRIBUTE_NONNULL(1);
>   |  ^~~~
> /usr/include/string.h:537:26: note: old declaration ‘const char* 
> basename(const char*)’
>   537 | extern "C++" const char *basename (const char *__filename)
>   |  ^~~~
> make[1]: *** [Makefile:2987: build/genmodes.o] Error 1
> make[1]: Leaving directory '/home/jonny/code/repos/gcc_tests/gcc_build/gcc'
> make: *** [Makefile:4996: all-gcc] Error 2
>
>
> Kind regards, Jonny


Re: [PATCH 2/4] libbacktrace: detect executable path on windows

2023-11-29 Thread Ian Lance Taylor via Gcc
On Mon, Nov 20, 2023 at 11:57 AM Björn Schäpers  wrote:
>
> this is what I'm using with GCC 12 and 13 on my windows machines, rebased onto
> the current HEAD.

Thanks.  Committed as follows.

Ian

* fileline.c: Include  if available.
(windows_get_executable_path): New static function.
(fileline_initialize): Call windows_get_executable_path.
* configure.ac: Checked for windows.h
* configure: Regenerate.
* config.h.in: Regenerate.
0ee01dfacbcc9bc05d11433a69c0a0ac13afa42f
diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in
index a4f5bf6..ee2616335c7 100644
--- a/libbacktrace/config.h.in
+++ b/libbacktrace/config.h.in
@@ -104,6 +104,9 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the  header file. */
+#undef HAVE_WINDOWS_H
+
 /* Define if -lz is available. */
 #undef HAVE_ZLIB
 
diff --git a/libbacktrace/configure b/libbacktrace/configure
index 0ccc060901d..7ade966b54d 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -13509,6 +13509,19 @@ $as_echo "#define HAVE_LOADQUERY 1" >>confdefs.h
 
 fi
 
+for ac_header in windows.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" 
"$ac_includes_default"
+if test "x$ac_cv_header_windows_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_WINDOWS_H 1
+_ACEOF
+
+fi
+
+done
+
+
 # Check for the fcntl function.
 if test -n "${with_target_subdir}"; then
case "${host}" in
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 71cd50f8cdf..00acb42eb6d 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -379,6 +379,8 @@ if test "$have_loadquery" = "yes"; then
   AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
 fi
 
+AC_CHECK_HEADERS(windows.h)
+
 # Check for the fcntl function.
 if test -n "${with_target_subdir}"; then
case "${host}" in
diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c
index 0e560b44e7a..773f3a92969 100644
--- a/libbacktrace/fileline.c
+++ b/libbacktrace/fileline.c
@@ -47,6 +47,18 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include 
 #endif
 
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_MEAN_AND_LEAN
+#define WIN32_MEAN_AND_LEAN
+#endif
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+#include 
+#endif
+
 #include "backtrace.h"
 #include "internal.h"
 
@@ -165,6 +177,37 @@ macho_get_executable_path (struct backtrace_state *state,
 
 #endif /* !HAVE_DECL__PGMPTR */
 
+#ifdef HAVE_WINDOWS_H
+
+#define FILENAME_BUF_SIZE (MAX_PATH)
+
+static char *
+windows_get_executable_path (char *buf, backtrace_error_callback 
error_callback,
+void *data)
+{
+  size_t got;
+  int error;
+
+  got = GetModuleFileNameA (NULL, buf, FILENAME_BUF_SIZE - 1);
+  error = GetLastError ();
+  if (got == 0
+  || (got == FILENAME_BUF_SIZE - 1 && error == ERROR_INSUFFICIENT_BUFFER))
+{
+  error_callback (data,
+ "could not get the filename of the current executable",
+ error);
+  return NULL;
+}
+  return buf;
+}
+
+#else /* !defined (HAVE_WINDOWS_H) */
+
+#define windows_get_executable_path(buf, error_callback, data) NULL
+#define FILENAME_BUF_SIZE 64
+
+#endif /* !defined (HAVE_WINDOWS_H) */
+
 /* Initialize the fileline information from the executable.  Returns 1
on success, 0 on failure.  */
 
@@ -178,7 +221,7 @@ fileline_initialize (struct backtrace_state *state,
   int called_error_callback;
   int descriptor;
   const char *filename;
-  char buf[64];
+  char buf[FILENAME_BUF_SIZE];
 
   if (!state->threaded)
 failed = state->fileline_initialization_failed;
@@ -202,7 +245,7 @@ fileline_initialize (struct backtrace_state *state,
 
   descriptor = -1;
   called_error_callback = 0;
-  for (pass = 0; pass < 9; ++pass)
+  for (pass = 0; pass < 10; ++pass)
 {
   int does_not_exist;
 
@@ -239,6 +282,9 @@ fileline_initialize (struct backtrace_state *state,
case 8:
  filename = macho_get_executable_path (state, error_callback, data);
  break;
+   case 9:
+ filename = windows_get_executable_path (buf, error_callback, data);
+ break;
default:
  abort ();
}