public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* amdgcn build failure
@ 2022-03-18 11:43 Andrew Stubbs
  2022-03-20  1:20 ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Stubbs @ 2022-03-18 11:43 UTC (permalink / raw)
  To: Newlib, Mike Frysinger

Hi Mike, all,

Following your commit 96bc16f, merged yesterday, my amdgcn toolchain 
fails to build. The Newlib built itself completes successfully, but 
subsequent use of the library is broken.

The problem seems to be related to the __malloc_lock function, but I 
can't quite work out why. Here's the error message:

ld: error: duplicate symbol: __malloc_lock
 >>> defined at mlock.c:42 (..../newlib/libc/stdlib/mlock.c:42)
 >>>            libc_a-mlock.o:(__malloc_lock) in archive 
..../amdgcn-amdhsa/lib/libc.a
 >>> defined at malloc_support.c:69 
(..../newlib/libc/machine/amdgcn/malloc_support.c:69)
 >>>            libc_a-malloc_support.o:(.text+0x1F8) in archive 
..../install/amdgcn-amdhsa/lib/libc.a

ld: error: duplicate symbol: __malloc_unlock
 >>> defined at malloc.h:138 (..../newlib/libc/include/malloc.h:138)
 >>>            libc_a-mlock.o:(__malloc_unlock) in archive 
..../amdgcn-amdhsa/lib/libc.a
 >>> defined at malloc_support.c:96 
(..../newlib/libc/machine/amdgcn/malloc_support.c:96)
 >>>            libc_a-malloc_support.o:(.text+0x438) in archive 
..../install/amdgcn-amdhsa/lib/libc.a
collect2: error: ld returned 1 exit status

(I should mention that the amdgcn port uses the LLVM binary utilities, 
so the error messages look a little different to GNU ld. I've also 
elided the long pathnames with "....".)

Previously only the machine-specific __malloc_lock was used, which is of 
course the one I want.

Should those functions be added differently now?

Thanks

Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: amdgcn build failure
  2022-03-18 11:43 amdgcn build failure Andrew Stubbs
@ 2022-03-20  1:20 ` Mike Frysinger
  2022-03-21 14:25   ` Andrew Stubbs
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2022-03-20  1:20 UTC (permalink / raw)
  To: Andrew Stubbs; +Cc: Newlib

[-- Attachment #1: Type: text/plain, Size: 2137 bytes --]

On 18 Mar 2022 11:43, Andrew Stubbs wrote:
> Following your commit 96bc16f, merged yesterday, my amdgcn toolchain 
> fails to build. The Newlib built itself completes successfully, but 
> subsequent use of the library is broken.
> 
> The problem seems to be related to the __malloc_lock function, but I 
> can't quite work out why. Here's the error message:
> 
> ld: error: duplicate symbol: __malloc_lock
>  >>> defined at mlock.c:42 (..../newlib/libc/stdlib/mlock.c:42)
>  >>>            libc_a-mlock.o:(__malloc_lock) in archive 
> ..../amdgcn-amdhsa/lib/libc.a
>  >>> defined at malloc_support.c:69 
> (..../newlib/libc/machine/amdgcn/malloc_support.c:69)
>  >>>            libc_a-malloc_support.o:(.text+0x1F8) in archive 
> ..../install/amdgcn-amdhsa/lib/libc.a
> 
> ld: error: duplicate symbol: __malloc_unlock
>  >>> defined at malloc.h:138 (..../newlib/libc/include/malloc.h:138)
>  >>>            libc_a-mlock.o:(__malloc_unlock) in archive 
> ..../amdgcn-amdhsa/lib/libc.a
>  >>> defined at malloc_support.c:96 
> (..../newlib/libc/machine/amdgcn/malloc_support.c:96)
>  >>>            libc_a-malloc_support.o:(.text+0x438) in archive 
> ..../install/amdgcn-amdhsa/lib/libc.a
> collect2: error: ld returned 1 exit status
> 
> (I should mention that the amdgcn port uses the LLVM binary utilities, 
> so the error messages look a little different to GNU ld. I've also 
> elided the long pathnames with "....".)

looks like amdgcn doesn't have a GNU port at all, so i can't really repro
this situation.  i can't explain why it changed.  it might be the overall
ordering changed because of assumptions in the build ...

> Previously only the machine-specific __malloc_lock was used, which is of 
> course the one I want.
> 
> Should those functions be added differently now?

i think you should always use the same name output if you want to override
regardless of my recent change.  the common code defines this in mlock.c,
so i would expect you to put your machine overrides in a mlock.c file in
your machine dir.

this is how all the setjmp, mem*, and str* funcs all work.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: amdgcn build failure
  2022-03-20  1:20 ` Mike Frysinger
@ 2022-03-21 14:25   ` Andrew Stubbs
  2022-03-23  1:45     ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Stubbs @ 2022-03-21 14:25 UTC (permalink / raw)
  To: Newlib

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On 20/03/2022 01:20, Mike Frysinger wrote:
> i think you should always use the same name output if you want to override
> regardless of my recent change.  the common code defines this in mlock.c,
> so i would expect you to put your machine overrides in a mlock.c file in
> your machine dir.
> 
> this is how all the setjmp, mem*, and str* funcs all work.
> -mike

OK, I've confirmed that this patch fixes it.

I don't believe I have the power to commit it myself.

Andrew

[-- Attachment #2: 220321-newlib-mlock-fix.patch --]
[-- Type: text/plain, Size: 9250 bytes --]

amdgcn: Fix build failure

The recent makefile reorganization broke the amdgcn port by creating
duplicate __malloc_lock symbols.  This patch fixes the problem by renaming
the malloc_support.c file to mlock.c, thus overriding the default symbol
properly.  Actually, I'm not sure how this ever worked?

diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index bdd41af02..3143308b0 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -708,7 +708,7 @@ check_PROGRAMS =
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/abort.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/exit.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/atexit.c \
-@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/malloc_support.c \
+@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/mlock.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/getreent.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/signal.c
 
@@ -2007,7 +2007,7 @@ am__objects_53 = libc/ssp/libc_a-chk_fail.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@am__objects_81 = libc/machine/amdgcn/libc_a-abort.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-exit.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-atexit.$(OBJEXT) \
-@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-malloc_support.$(OBJEXT) \
+@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-mlock.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-getreent.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-signal.$(OBJEXT)
 @HAVE_LIBC_MACHINE_ARC_TRUE@am__objects_82 = libc/machine/arc/libc_a-memcmp.$(OBJEXT) \
@@ -8081,7 +8081,7 @@ libc/machine/amdgcn/libc_a-exit.$(OBJEXT):  \
 libc/machine/amdgcn/libc_a-atexit.$(OBJEXT):  \
 	libc/machine/amdgcn/$(am__dirstamp) \
 	libc/machine/amdgcn/$(DEPDIR)/$(am__dirstamp)
-libc/machine/amdgcn/libc_a-malloc_support.$(OBJEXT):  \
+libc/machine/amdgcn/libc_a-mlock.$(OBJEXT):  \
 	libc/machine/amdgcn/$(am__dirstamp) \
 	libc/machine/amdgcn/$(DEPDIR)/$(am__dirstamp)
 libc/machine/amdgcn/libc_a-getreent.$(OBJEXT):  \
@@ -12242,7 +12242,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-atexit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-getreent.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-signal.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/arc/$(DEPDIR)/libc_a-memcmp-bs-norm.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/arc/$(DEPDIR)/libc_a-memcmp-stub.Po@am__quote@
@@ -33397,19 +33397,19 @@ libc/machine/amdgcn/libc_a-atexit.obj: libc/machine/amdgcn/atexit.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-atexit.obj `if test -f 'libc/machine/amdgcn/atexit.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/atexit.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/atexit.c'; fi`
 
-libc/machine/amdgcn/libc_a-malloc_support.o: libc/machine/amdgcn/malloc_support.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-malloc_support.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Tpo -c -o libc/machine/amdgcn/libc_a-malloc_support.o `test -f 'libc/machine/amdgcn/malloc_support.c' || echo '$(srcdir)/'`libc/machine/amdgcn/malloc_support.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/malloc_support.c' object='libc/machine/amdgcn/libc_a-malloc_support.o' libtool=no @AMDEPBACKSLASH@
+libc/machine/amdgcn/libc_a-mlock.o: libc/machine/amdgcn/mlock.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-mlock.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Tpo -c -o libc/machine/amdgcn/libc_a-mlock.o `test -f 'libc/machine/amdgcn/mlock.c' || echo '$(srcdir)/'`libc/machine/amdgcn/mlock.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/mlock.c' object='libc/machine/amdgcn/libc_a-mlock.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-malloc_support.o `test -f 'libc/machine/amdgcn/malloc_support.c' || echo '$(srcdir)/'`libc/machine/amdgcn/malloc_support.c
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-mlock.o `test -f 'libc/machine/amdgcn/mlock.c' || echo '$(srcdir)/'`libc/machine/amdgcn/mlock.c
 
-libc/machine/amdgcn/libc_a-malloc_support.obj: libc/machine/amdgcn/malloc_support.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-malloc_support.obj -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Tpo -c -o libc/machine/amdgcn/libc_a-malloc_support.obj `if test -f 'libc/machine/amdgcn/malloc_support.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/malloc_support.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/malloc_support.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-malloc_support.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/malloc_support.c' object='libc/machine/amdgcn/libc_a-malloc_support.obj' libtool=no @AMDEPBACKSLASH@
+libc/machine/amdgcn/libc_a-mlock.obj: libc/machine/amdgcn/mlock.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-mlock.obj -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Tpo -c -o libc/machine/amdgcn/libc_a-mlock.obj `if test -f 'libc/machine/amdgcn/mlock.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/mlock.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/mlock.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/mlock.c' object='libc/machine/amdgcn/libc_a-mlock.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-malloc_support.obj `if test -f 'libc/machine/amdgcn/malloc_support.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/malloc_support.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/malloc_support.c'; fi`
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-mlock.obj `if test -f 'libc/machine/amdgcn/mlock.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/mlock.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/mlock.c'; fi`
 
 libc/machine/amdgcn/libc_a-getreent.o: libc/machine/amdgcn/getreent.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-getreent.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-getreent.Tpo -c -o libc/machine/amdgcn/libc_a-getreent.o `test -f 'libc/machine/amdgcn/getreent.c' || echo '$(srcdir)/'`libc/machine/amdgcn/getreent.c
diff --git a/newlib/libc/machine/amdgcn/Makefile.inc b/newlib/libc/machine/amdgcn/Makefile.inc
index 6253e4d70..d26603aa8 100644
--- a/newlib/libc/machine/amdgcn/Makefile.inc
+++ b/newlib/libc/machine/amdgcn/Makefile.inc
@@ -2,6 +2,6 @@ libc_a_SOURCES += \
 	%D%/abort.c \
 	%D%/exit.c \
 	%D%/atexit.c \
-	%D%/malloc_support.c \
+	%D%/mlock.c \
 	%D%/getreent.c \
 	%D%/signal.c
diff --git a/newlib/libc/machine/amdgcn/malloc_support.c b/newlib/libc/machine/amdgcn/mlock.c
similarity index 100%
rename from newlib/libc/machine/amdgcn/malloc_support.c
rename to newlib/libc/machine/amdgcn/mlock.c

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: amdgcn build failure
  2022-03-21 14:25   ` Andrew Stubbs
@ 2022-03-23  1:45     ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2022-03-23  1:45 UTC (permalink / raw)
  To: Andrew Stubbs; +Cc: Newlib

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

On 21 Mar 2022 14:25, Andrew Stubbs wrote:
> On 20/03/2022 01:20, Mike Frysinger wrote:
> > i think you should always use the same name output if you want to override
> > regardless of my recent change.  the common code defines this in mlock.c,
> > so i would expect you to put your machine overrides in a mlock.c file in
> > your machine dir.
> > 
> > this is how all the setjmp, mem*, and str* funcs all work.
> 
> OK, I've confirmed that this patch fixes it.
> 
> I don't believe I have the power to commit it myself.

pushed for you
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-23  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 11:43 amdgcn build failure Andrew Stubbs
2022-03-20  1:20 ` Mike Frysinger
2022-03-21 14:25   ` Andrew Stubbs
2022-03-23  1:45     ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).