diff mbox series

Remove installed header rule on $(..)include/%.h

Message ID 20240109182520.2166103-1-hjl.tools@gmail.com
State New
Headers show
Series Remove installed header rule on $(..)include/%.h | expand

Commit Message

H.J. Lu Jan. 9, 2024, 6:25 p.m. UTC
On x86-64 machine with

[hjl@gnu-cfl-3 x86-glibc]$ ls -l /usr/include/asm/prctl.h sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 hjl  hjl   825 Jan  9 09:41 sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 root root 1170 Nov 27 16:00 /usr/include/asm/prctl.h
[hjl@gnu-cfl-3 x86-glibc]$

glibc configured with --enable-cet build failed:

make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
../Makerules:327: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.stmp
:
../Makeconfig:1216: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.stmp
:
../Makerules:1126: update target '/usr/include/asm/prctl.h' due to:
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
force-install
/usr/bin/install -c -m 644
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
/usr/include/asm/prctl.h
/usr/bin/install: cannot remove '/usr/include/asm/prctl.h': Permission denied
make[2]: *** [../Makerules:1126: /usr/include/asm/prctl.h] Error 1
make[2]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
make[1]: *** [Makefile:484: iconv/subdir_lib] Error 2
make[1]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc'
make: *** [Makefile:9: all] Error 2

This is triggered by the rule in Makerules:

$(inst_includedir)/%.h: $(..)include/%.h $(+force)
  $(do-install)

Since no files under include/ should be installed, remove it from
Makerules.

Tested it on x86-64.  There are no differences in the installed header
files.
---
 Makerules | 2 --
 1 file changed, 2 deletions(-)

Comments

Adhemerval Zanella Netto Jan. 9, 2024, 6:30 p.m. UTC | #1
On 09/01/24 15:25, H.J. Lu wrote:
> On x86-64 machine with
> 
> [hjl@gnu-cfl-3 x86-glibc]$ ls -l /usr/include/asm/prctl.h sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
> -rw-r--r-- 1 hjl  hjl   825 Jan  9 09:41 sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
> -rw-r--r-- 1 root root 1170 Nov 27 16:00 /usr/include/asm/prctl.h
> [hjl@gnu-cfl-3 x86-glibc]$
> 
> glibc configured with --enable-cet build failed:
> 
> make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
> ../Makerules:327: update target
> '/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.h'
> due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.stmp
> :
> ../Makeconfig:1216: update target
> '/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.h'
> due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.stmp
> :
> ../Makerules:1126: update target '/usr/include/asm/prctl.h' due to:
> ../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
> force-install
> /usr/bin/install -c -m 644
> ../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
> /usr/include/asm/prctl.h
> /usr/bin/install: cannot remove '/usr/include/asm/prctl.h': Permission denied
> make[2]: *** [../Makerules:1126: /usr/include/asm/prctl.h] Error 1
> make[2]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
> make[1]: *** [Makefile:484: iconv/subdir_lib] Error 2
> make[1]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc'
> make: *** [Makefile:9: all] Error 2
> 
> This is triggered by the rule in Makerules:
> 
> $(inst_includedir)/%.h: $(..)include/%.h $(+force)
>   $(do-install)
> 
> Since no files under include/ should be installed, remove it from
> Makerules.
> 
> Tested it on x86-64.  There are no differences in the installed header
> files.

I stumbled on this for my clang/glibc branch [1] and I was puzzled why this
rule was initially added (I couldn't find it on git history nor it seems
obvious why).

LGTM, thanks.  Although It would be good to know why if was required
in first place.

> ---
>  Makerules | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/Makerules b/Makerules
> index a000bf7b5e..00365bc58b 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -1122,8 +1122,6 @@ $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
>  	$(do-install)
>  $(inst_includedir)/%.h: %.h $(+force)
>  	$(do-install)
> -$(inst_includedir)/%.h: $(..)include/%.h $(+force)
> -	$(do-install)
>  headers-nonh := $(filter-out %.h,$(headers))
>  ifdef headers-nonh
>  $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=9059d804d9870f6e937bf8073fa9af6a911f8c97
Andreas Schwab Jan. 9, 2024, 8:11 p.m. UTC | #2
On Jan 09 2024, H.J. Lu wrote:

> Since no files under include/ should be installed

include/features.h is an installed header.
H.J. Lu Jan. 9, 2024, 8:17 p.m. UTC | #3
On Tue, Jan 9, 2024 at 12:11 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Jan 09 2024, H.J. Lu wrote:
>
> > Since no files under include/ should be installed
>
> include/features.h is an installed header.
>

It is a special case handled in Makefile by

headers := limits.h values.h features.h features-time64.h gnu-versions.h \
           bits/xopen_lim.h gnu/libc-version.h stdc-predef.h \
           bits/libc-header-start.h
Andreas Schwab Jan. 9, 2024, 8:24 p.m. UTC | #4
On Jan 09 2024, H.J. Lu wrote:

> On Tue, Jan 9, 2024 at 12:11 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>
>> On Jan 09 2024, H.J. Lu wrote:
>>
>> > Since no files under include/ should be installed
>>
>> include/features.h is an installed header.
>>
>
> It is a special case handled in Makefile by

There is no special case.
H.J. Lu Jan. 9, 2024, 9:24 p.m. UTC | #5
On Tue, Jan 9, 2024 at 12:24 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Jan 09 2024, H.J. Lu wrote:
>
> > On Tue, Jan 9, 2024 at 12:11 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >>
> >> On Jan 09 2024, H.J. Lu wrote:
> >>
> >> > Since no files under include/ should be installed
> >>
> >> include/features.h is an installed header.
> >>
> >
> > It is a special case handled in Makefile by
>
> There is no special case.
>

Header files under include aren't installed via Makefiles in
subdirectories.  The following header files are installed by
top level Makefile:

eaders := limits.h values.h features.h features-time64.h gnu-versions.h \
           bits/xopen_lim.h gnu/libc-version.h stdc-predef.h \
           bits/libc-header-start.h

echo-headers: subdir_echo-headers

# The headers are in the include directory.
subdir-dirs = include
vpath %.h $(subdir-dirs)
diff mbox series

Patch

diff --git a/Makerules b/Makerules
index a000bf7b5e..00365bc58b 100644
--- a/Makerules
+++ b/Makerules
@@ -1122,8 +1122,6 @@  $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
 	$(do-install)
 $(inst_includedir)/%.h: %.h $(+force)
 	$(do-install)
-$(inst_includedir)/%.h: $(..)include/%.h $(+force)
-	$(do-install)
 headers-nonh := $(filter-out %.h,$(headers))
 ifdef headers-nonh
 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \