sim: ppc: fallback when ln is not available [PR sim/18864]

Message ID 20211003153724.8246-1-vapier@gentoo.org
State New
Headers show
Series
  • sim: ppc: fallback when ln is not available [PR sim/18864]
Related show

Commit Message

Tom de Vries via Gdb-patches Oct. 3, 2021, 3:37 p.m.
Not all systems have easy access to hard links or symlinks, so add
fallback logic to the run->psim build code to handle those.

Bug: https://sourceware.org/PR18864
---
 sim/arch-subdir.mk.in | 1 +
 sim/ppc/Makefile.in   | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

-- 
2.33.0

Patch

diff --git a/sim/arch-subdir.mk.in b/sim/arch-subdir.mk.in
index efd91e76b1c3..96b481a97e25 100644
--- a/sim/arch-subdir.mk.in
+++ b/sim/arch-subdir.mk.in
@@ -26,6 +26,7 @@  EXEEXT = @EXEEXT@
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+LN_S = @LN_S@
 
 CC = @CC@
 C_DIALECT = @C_DIALECT@
diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in
index 9d892ee5999f..c230f29d6883 100644
--- a/sim/ppc/Makefile.in
+++ b/sim/ppc/Makefile.in
@@ -522,8 +522,8 @@  psim$(EXEEXT): $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(LIBINTL_DEP)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETLIB) $(BFD_LIB) $(ZLIB) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS)
 
 run$(EXEEXT): psim$(EXEEXT)
-	rm -f run$(EXEEXT)
-	ln psim$(EXEEXT) run$(EXEEXT)
+	rm -f $@
+	ln $< $@ 2>/dev/null || $(LN_S) $< $@ 2>/dev/null || cp -p $< $@
 
 $(TARGETLIB): tmp-igen tmp-dgen tmp-hw tmp-pk tmp-defines $(LIB_OBJ) $(GDB_OBJ)
 	rm -f $(TARGETLIB)