diff mbox series

[ada,build] Avoid cp -p failures during Ada make install

Message ID yddk1f1tl0a.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series [ada,build] Avoid cp -p failures during Ada make install | expand

Commit Message

Rainer Orth May 8, 2019, 8:20 a.m. UTC
Prompted by a known make install failure on Linux/x86_64, I decided to
finally rework my ancient patch

	http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01669.html

along the lines Mike suggested back then, i.e. use cp && touch -r
instead of cp -p.  This avoids the failures like

for file in rts/*.ad[sb]*; do \
    cp -p $file /vol/gcc/obj/gcc/gcc-10/vol/gcc/lib/gcc/x86_64-pc-linux-gnu/10.0.0/adainclude; \
done
cp: preserving permissions for ‘/vol/gcc/obj/gcc/gcc-10/vol/gcc/lib/gcc/x86_64-pc-linux-gnu/10.0.0/adainclude/a-assert.adb’: Operation not supported

when installing e.g. to an NFSv3 destination which doesn't support POSIX
ACLs from a local filesystem that does.

The fix turned out to be a bit more involved than I initially thought:

* I've changed INSTALL_DATA_DATE to use GNU make's $(call) function
  since the args are now needed twice.

* The destination argument now needs to include the filename: while cp
  can use a directory as destination, touch -r needs the full filename
  to preserve the timestamps.

* In order for $(notdir) to work which operates textually on its args,
  the loops had to be changed from shell for loops to make $(foreach)
  loops.

* And finally, to avoid exceeding the command line length limit, the
  individual commands have been separate by newlines, a trick learned
  from https://stackoverflow.com/questions/7039811/how-do-i-process-extremely-long-lists-of-files-in-a-make-recipe

When first testing this, the make install failed trying to install
standard.ads.h: while this gave just a warning with the old code

cp: cannot stat 'rts/standard.ads.h': No such file or directory

it now fails.  It turns out this is a dangling symlink

$ ls -l gcc/ada/rts/standard.ads.h
lrwxrwxrwx 1 ro gcc 50 May  7 18:13 gcc/ada/rts/standard.ads.h -> /vol/gcc/src/hg/trunk/local/gcc/ada/standard.ads.h
$ ls -lL gcc/ada/rts/standard.ads.h
ls: cannot access 'gcc/ada/rts/standard.ads.h': No such file or directory

introduced in r260921.  This is only present on mainline and the gcc-9
branch and the file seems never to have existed in tree, so I'm just
removing the reference.

Tested on x86_64-pc-linux-gnu installing both to a local filesystem and
an NFSv3 filesystem.

Ok for mainline (and the gcc-9 and gcc-8 branches eventually)?

Thanks.
	Rainer

Comments

Arnaud Charlet May 8, 2019, 9:08 a.m. UTC | #1
> Tested on x86_64-pc-linux-gnu installing both to a local filesystem and
> an NFSv3 filesystem.
> 
> Ok for mainline (and the gcc-9 and gcc-8 branches eventually)?

No, this is not OK.

I'd rather keep the simple current logic and either stick to cp -p, or
use a proper $(INSTALL_whatever) as done elsewhere rather than adding more
kludges.

Also, standard.ads.h is a valid file, so the reference shouldn't be removed.

I'll add it to the repository, this was an oversight, thanks for noticing.

Arno
Arnaud Charlet May 8, 2019, 9:57 a.m. UTC | #2
> Also, standard.ads.h is a valid file, so the reference shouldn't be removed.
> 
> I'll add it to the repository, this was an oversight, thanks for noticing.

I've added it now.

2019-05-08  Arnaud Charlet  <charlet@adacore.com>

	* standard.ads.h: New file.
Rainer Orth May 13, 2019, 9:13 a.m. UTC | #3
Hi Arnaud,

>> Tested on x86_64-pc-linux-gnu installing both to a local filesystem and
>> an NFSv3 filesystem.
>> 
>> Ok for mainline (and the gcc-9 and gcc-8 branches eventually)?
>
> No, this is not OK.
>
> I'd rather keep the simple current logic and either stick to cp -p, or
> use a proper $(INSTALL_whatever) as done elsewhere rather than adding more
> kludges.

how do you mean, `proper $(INSTALL_whatever)'?

I've run the cp -p under strace, which shows

fgetxattr(3, "system.posix_acl_access", 0x7fff96829fd0, 132) = -1 ENODATA (No data available)
fstat(3, {st_mode=S_IFREG|0644, st_size=35368, ...}) = 0
fsetxattr(4, "system.posix_acl_access", "\2\0\0\0\1\0\6\0\377\377\377\377\4\0\4\0\377\377\377\377 \0\4\0\377\377\377\377", 28, 0) = -1 EOPNOTSUPP (Operation not supported)

i.e. it tries to determine an extended attribute, is told there's none,
tries to set that none on the destination and chokes if that doesn't
work.  Seems pretty insane to me.

This is cp from coreutils 8.30 on Fedora 29, btw., not same ancient
prehistoric software.

	Rainer
Arnaud Charlet May 13, 2019, 9:43 a.m. UTC | #4
> > No, this is not OK.
> >
> > I'd rather keep the simple current logic and either stick to cp -p, or
> > use a proper $(INSTALL_whatever) as done elsewhere rather than adding more
> > kludges.
> 
> how do you mean, `proper $(INSTALL_whatever)'?

Using e.g. INSTALL_DATA from configure.

> I've run the cp -p under strace, which shows
> 
> fgetxattr(3, "system.posix_acl_access", 0x7fff96829fd0, 132) = -1 ENODATA (No data available)
> fstat(3, {st_mode=S_IFREG|0644, st_size=35368, ...}) = 0
> fsetxattr(4, "system.posix_acl_access", "\2\0\0\0\1\0\6\0\377\377\377\377\4\0\4\0\377\377\377\377 \0\4\0\377\377\377\377", 28, 0) = -1 EOPNOTSUPP (Operation not supported)
> 
> i.e. it tries to determine an extended attribute, is told there's none,
> tries to set that none on the destination and chokes if that doesn't
> work.  Seems pretty insane to me.
> 
> This is cp from coreutils 8.30 on Fedora 29, btw., not same ancient
> prehistoric software.

Did someone file a bug report there BTW?

Arno
diff mbox series

Patch

# HG changeset patch
# Parent  53354151a0c54f05832420ddfa64adf8e22f6251
Avoid cp -p failures during Ada make install

diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -2610,7 +2610,7 @@  LIBGNAT_OBJS = adadecode.o adaint.o argv
 #  from ADA_INCLUDE_SRCS.
 
 LIBGNAT_SRCS = $(patsubst %.o,%.c,$(LIBGNAT_OBJS))			\
-  adadecode.h adaint.h env.h gsocket.h raise.h standard.ads.h		\
+  adadecode.h adaint.h env.h gsocket.h raise.h				\
   tb-gcc.c libgnarl/thread.c $(EXTRA_LIBGNAT_SRCS)
 
 # memtrack.o is special as not put into libgnat.
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -98,7 +98,7 @@  COMPILER_FLAGS = $(CFLAGS)
 SHELL = @SHELL@
 PWD_COMMAND = $${PWDCMD-pwd}
 # How to copy preserving the date
-INSTALL_DATA_DATE = cp -p
+INSTALL_DATA_DATE = cp $(1) $(2) && touch -r $(1) $(2)
 MAKEINFO = makeinfo
 TEXI2DVI = texi2dvi
 TEXI2PDF = texi2pdf
@@ -502,26 +502,31 @@  gnatlink-re: ../stamp-tools gnatmake-re
 	  true; \
 	fi
 
+# Used as line separator to avoid overflowing command lines.
+define NL
+
+
+endef
+
 install-gcc-specs:
 #	Install all the requested GCC spec files.
 
-	$(foreach f,$(GCC_SPEC_FILES), \
-	    $(INSTALL_DATA_DATE) $(srcdir)/ada/$(f) $(DESTDIR)$(libsubdir)/;)
+	$(foreach f, $(GCC_SPEC_FILES), \
+	    $(call INSTALL_DATA_DATE, $(srcdir)/ada/$(f), $(libsubdir))/$(notdir $(f));)
 
 install-gnatlib: ../stamp-gnatlib-$(RTSDIR) install-gcc-specs
 	$(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
 	$(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
 	-$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
 	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
-	for file in $(RTSDIR)/*.ali; do \
-	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
-	done
+	$(foreach file, $(wildcard $(RTSDIR)/*.ali), \
+	    $(call INSTALL_DATA_DATE, $(file), $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$(notdir $(file)))$(NL))
 	-cd $(RTSDIR); for file in *$(arext);do \
 	    $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
 	    $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \
 	done
 	-$(foreach file, $(EXTRA_ADALIB_OBJS), \
-	    $(INSTALL_DATA_DATE) $(RTSDIR)/$(file) $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \
+	    $(call INSTALL_DATA_DATE,$(RTSDIR)/$(file),$(DESTDIR)$(ADA_RTL_OBJ_DIR)/$(notdir $(file))$(NL)) && \
 	) true
 #     Install the shared libraries, if any, using $(INSTALL) instead
 #     of $(INSTALL_DATA). The latter may force a mode inappropriate
@@ -544,9 +549,8 @@  install-gnatlib: ../stamp-gnatlib-$(RTSD
 	   fi; \
 	done
 # This copy must be done preserving the date on the original file.
-	for file in $(RTSDIR)/*.ad[sb]*; do \
-	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \
-	done
+	$(foreach file, $(wildcard $(RTSDIR)/*.ad[sb]*), \
+	    $(call INSTALL_DATA_DATE, $(file), $(DESTDIR)$(ADA_INCLUDE_DIR)/$(notdir $(file)))$(NL))
 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads