[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

Richard Biener  changed:

   What|Removed |Added

Version|unknown |14.1.0
   Target Milestone|--- |13.4

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-11 Thread syq at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

--- Comment #7 from YunQiang Su  ---
Maybe this patch is better

--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -560,11 +560,7 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
 NATIVE_SYSTEM_HEADER_DIR = @NATIVE_SYSTEM_HEADER_DIR@
 # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
-ifeq (@includedir@,$(prefix)/include)
-  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
-else
-  CROSS_SYSTEM_HEADER_DIR = @includedir@
-endif
+CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@

 # autoconf sets SYSTEM_HEADER_DIR to one of the above.
 # Purge it of unnecessary internal relative paths
@@ -581,7 +577,10 @@ BUILD_SYSTEM_HEADER_DIR = `echo @BUILD_SYSTEM_HEADER_DIR@
| sed -e :a -e 's,[^/]
 STMP_FIXINC = @STMP_FIXINC@

 # Test to see whether  exists in the system header files.
-LIMITS_H_TEST = [ -f $(BUILD_SYSTEM_HEADER_DIR)/limits.h ]
+LIMITS_H_TEST = headdir=$(BUILD_SYSTEM_HEADER_DIR) && \
+   headdir_sys=`echo $$headdir | grep '/sys-include$$'` && \
+   headdir_nosys=`echo $$headdir | sed 's/sys-include/include/'`
&& \
+   [ -f $$headdir/limits.h -o -n $$headdir_sys -a -f
"$$headdir_nosys/limits.h" ]

 # Directory for prefix to system directories, for
 # each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.


Background: For cross/no-with-sysroot, the BUILD_SYSTEM_HEADER_DIR value will
be `$(gcc_tooldir)/sys-include`.  Here, `sys-include` is used by
`--with-headers` option.


So let's detect $(gcc_tooldir)/include too.

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-10 Thread syq at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

--- Comment #6 from YunQiang Su  ---
(In reply to Marcus Calhoun-Lopez from comment #5)
> (In reply to YunQiang Su from comment #3)
> > Since it doesn't exist, why use --includedir with it?
> 
> /opt/local/include/gcc is where the header files will be installed after the
> build, so there is no reason for it to exist before the build.
> 

Normally, we build gcc for 1st stage with/without --includedir, 
and then build libc with 1st stage gcc, and install the libc into the
destination.
Then we build gcc stage2 with --includedir.


Ohh, in fact that I am worrying that both you and I have a mistake: the
--includedir may be used for host instead of target.

Should we introduce a new build-time option?

Background: I add this patch due to Debian's cross toolchain install headers
into /usr//include
instead of /usr//sys-include

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-10 Thread marcuscalhounlopez at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

--- Comment #5 from Marcus Calhoun-Lopez  
---
(In reply to YunQiang Su from comment #3)
> Since it doesn't exist, why use --includedir with it?

/opt/local/include/gcc is where the header files will be installed after the
build, so there is no reason for it to exist before the build.

> Anyway, so, maybe we should detect the existence of this dir.
> Can you have a try of this patch?
> 
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -560,10 +560,11 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
>  # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
>  NATIVE_SYSTEM_HEADER_DIR = @NATIVE_SYSTEM_HEADER_DIR@
>  # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
> -ifeq (@includedir@,$(prefix)/include)
> -  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
> -else
> -  CROSS_SYSTEM_HEADER_DIR = @includedir@
> +CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
> +ifneq (@includedir@,$(prefix)/include)
> +  ifneq (,$(wildcard @includedir@))
> +CROSS_SYSTEM_HEADER_DIR = @includedir@
> +  endif
>  endif

Yes, this seems to work.
Thank you very much.

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-10 Thread marcuscalhounlopez at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

--- Comment #4 from Marcus Calhoun-Lopez  
---
(In reply to YunQiang Su from comment #2)
> Can you give me the configure command, so that I can have a test.

The pertinent part of the configure command is
`configure --prefix=/opt/local --includedir=/opt/local/include/gcc
--libdir=/opt/local/lib/libgcc`

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-10 Thread syq at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

--- Comment #3 from YunQiang Su  ---
Since it doesn't exist, why use --includedir with it?
Anyway, so, maybe we should detect the existence of this dir.
Can you have a try of this patch?

--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -560,10 +560,11 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
 NATIVE_SYSTEM_HEADER_DIR = @NATIVE_SYSTEM_HEADER_DIR@
 # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
-ifeq (@includedir@,$(prefix)/include)
-  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
-else
-  CROSS_SYSTEM_HEADER_DIR = @includedir@
+CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
+ifneq (@includedir@,$(prefix)/include)
+  ifneq (,$(wildcard @includedir@))
+CROSS_SYSTEM_HEADER_DIR = @includedir@
+  endif
 endif

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-10 Thread syq at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

--- Comment #2 from YunQiang Su  ---
Can you give me the configure command, so that I can have a test.

[Bug bootstrap/115416] [13/14/15 regression] Setting --includedir to a nonexistent directory causes a build error since r13-5490-g59e4c98173a79f

2024-06-10 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115416

Sam James  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   See Also||https://bugs.gentoo.org/sho
   ||w_bug.cgi?id=905118,
   ||https://bugs.gentoo.org/sho
   ||w_bug.cgi?id=925204,
   ||https://bugs.gentoo.org/sho
   ||w_bug.cgi?id=926059
   Last reconfirmed||2024-06-10
 Ever confirmed|0   |1