Bug 170439 - [MAINTAINER] lang/gcc-aux: Automatically add rpath to every created binary
Summary: [MAINTAINER] lang/gcc-aux: Automatically add rpath to every created binary
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Frederic Culot
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-07 07:30 UTC by John Marino
Modified: 2012-08-09 07:30 UTC (History)
0 users

See Also:


Attachments
file.txt (2.89 KB, text/plain)
2012-08-07 07:30 UTC, John Marino
no flags Details
diff.gcc-aux2.txt (3.18 KB, text/plain)
2012-08-08 11:56 UTC, John Marino
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Marino 2012-08-07 07:30:02 UTC
The gcc-aux compiler installs at /usr/local/gcc-aux, which means libraries such as libgcc_s.so and libstdc++.so are installed in the non-standard library location of /usr/local/gcc-aux/lib.

The accompanying patch updates the FreeBSD LINK_SPEC to automatically add an rpath to every generated dynamic binary that will point at this locate.  Without this running the binary would require the environment variable LD_LIBRARY_PATH would have to be set, or the path would have to be manual incorporated into the ld-elf.so.hints file by every user.

At the same time, --hash-style=both was added to LINK_SPEC of dynamic binaries.  This will allow faster symbol matching for dynamic linkers that support the tag (FreeBSD 10, FreeBSD 9.1+ (I think))

Files updated:
Makefile
files/diff-core

Fix: Patch attached with submission follows:
Comment 1 Frederic Culot freebsd_committer freebsd_triage 2012-08-07 09:16:02 UTC
Responsible Changed
From-To: freebsd-ports-bugs->culot

I'll take it.
Comment 2 Frederic Culot freebsd_committer freebsd_triage 2012-08-08 09:59:57 UTC
Hi John,

the submitted patch builds fine on FreeBSD 10 and 9 but I have issues
on 8.3 as shown here:

https://redports.org/~culot/20120807103217-9553-45723/gcc-aux-20120614_1.log

The hash-style=both seems to cause trouble.
Could you please check the logs John and tell me how to proceed?

Many thanks,
Frederic
Comment 3 John Marino 2012-08-08 10:17:18 UTC
On 8/8/2012 10:59, Frederic Culot wrote:
> Hi John,
>
> the submitted patch builds fine on FreeBSD 10 and 9 but I have issues
> on 8.3 as shown here:
>
> https://redports.org/~culot/20120807103217-9553-45723/gcc-aux-20120614_1.log
>
> The hash-style=both seems to cause trouble.
> Could you please check the logs John and tell me how to proceed?
>
> Many thanks,
> Frederic

Hi Frederic,
It appears the FreeBSD 7 and probably Freebsd 8 (which I can't access at 
the moment) are still on binutils 2.15 which FreeBSD 9+ are on binutils 
2.17.50.  The latter recognizes --hash-style and the former doesn't.

There are two options I see:
1) Lowest common denominator: remove --hash-style.  Performance will 
suffer on FreeBSD 9 and 10, but it will build everywhere
2) Rework freebsd file to add this tag based on __FreeBSD__ value.  This 
will conserve performance on recent FreeBSD and allow build on prior 
versions.  It should work, but I need to test this.

I take it that you prefer option 2?  I think I would.
John
Comment 4 John Marino 2012-08-08 11:56:07 UTC
Hi Frederic,

Here is an updated patch (attached).
I tested it on FreeBSD 8 and FreeBSD 9, and both built successfully with 
it.  It will insert hash-style for FreeBSD 9 and higher.

Regards,
John
Comment 5 dfilter service freebsd_committer freebsd_triage 2012-08-09 07:29:54 UTC
Author: culot
Date: Thu Aug  9 06:29:42 2012
New Revision: 302328
URL: http://svn.freebsd.org/changeset/ports/302328

Log:
  - Update diff-core patch to allow faster symbol matching on FreeBSD>=9
  - Fix shared libraries issues by automatically adding rpath to generated
    binaries
  - Bump portrevision
  
  PR:		ports/170439
  Submitted by:	John Marino <draco@marino.st> (maintainer)

Modified:
  head/lang/gcc-aux/Makefile
  head/lang/gcc-aux/files/diff-core

Modified: head/lang/gcc-aux/Makefile
==============================================================================
--- head/lang/gcc-aux/Makefile	Thu Aug  9 05:45:13 2012	(r302327)
+++ head/lang/gcc-aux/Makefile	Thu Aug  9 06:29:42 2012	(r302328)
@@ -7,6 +7,7 @@
 
 PORTNAME=	gcc-aux
 PORTVERSION=	${SNAPSHOT}
+PORTREVISION=	1
 CATEGORIES=	lang
 MASTER_SITES=	http://downloads.dragonlace.net/src/:boot \
 		http://dragonlace.mirrors.ada.cx/src/:boot \
@@ -201,6 +202,12 @@ post-extract:
 	@${PATCH} -d ${WRKSRC} -s -E < ${FILESDIR}/diff-${suffix}
 .endfor
 
+	# Update LINK_SPEC to add gcc-aux lib runpath in every binary
+	@${ECHO} "Configuring LINK_SPEC runpath"
+	@perl -pi -e 's;\@PREFIX\@;${PREFIX};' \
+	  ${WRKSRC}/gcc/config/i386/freebsd64.h \
+	  ${WRKSRC}/gcc/config/i386/freebsd.h
+
 .if defined(WITH_STATIC)
 	@${ECHO} "Reconfiguring GCC Makefile to build compiler statically"
 	@${PATCH} -d ${WRKSRC} -s -E < ${FILESDIR}/diff-static-version

Modified: head/lang/gcc-aux/files/diff-core
==============================================================================
--- head/lang/gcc-aux/files/diff-core	Thu Aug  9 05:45:13 2012	(r302327)
+++ head/lang/gcc-aux/files/diff-core	Thu Aug  9 06:29:42 2012	(r302328)
@@ -199,7 +199,7 @@
 +#define UINTPTR_TYPE      (LONG_TYPE_SIZE == 64 ? UINT64_TYPE : UINT32_TYPE)
 --- /dev/null
 +++ gcc/config/dragonfly.h
-@@ -0,0 +1,135 @@
+@@ -0,0 +1,136 @@
 +/* Base configuration file for all DragonFly targets.
 +   Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc.
 +
@@ -286,8 +286,9 @@
 +    %{rdynamic:-export-dynamic} \
 +    -dynamic-linker %(dfbsd_dynamic_linker) \
 +   } \
-+  %{static:-Bstatic}} \
-+  %{!static:--hash-style=both} \
++   %{static:-Bstatic} \
++  } \
++  %{!static:--hash-style=both -rpath @PREFIX@/gcc-aux/lib} \
 +  %{symbolic:-Bsymbolic}"
 +
 +#undef  LINK_SPEC
@@ -572,15 +573,54 @@
 +
 --- gcc/config/i386/freebsd.h.orig
 +++ gcc/config/i386/freebsd.h
-@@ -148,3 +148,5 @@
+@@ -91,6 +91,12 @@
+    When the -shared link option is used a final link is not being
+    done.  */
+ 
++#if FBSD_MAJOR < 9
++#define ELF_HASH_STYLE ""
++#else
++#define ELF_HASH_STYLE "--hash-style=both "
++#endif
++
+ #undef	LINK_SPEC
+ #define LINK_SPEC "\
+   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
+@@ -102,6 +108,7 @@
+         %{rdynamic:-export-dynamic} \
+         -dynamic-linker %(fbsd_dynamic_linker) } \
+     %{static:-Bstatic}} \
++  %{!static:" ELF_HASH_STYLE "-rpath @PREFIX@/gcc-aux/lib} \
+   %{symbolic:-Bsymbolic}"
+ 
+ /* A C statement to output to the stdio stream FILE an assembler
+@@ -148,3 +155,5 @@
  
  #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
  
 +/* Compile in __enable_execute_stack (void *) (see config.host) */
 +#define HAVE_ENABLE_EXECUTE_STACK
+--- gcc/config/i386/freebsd64.h.orig
++++ gcc/config/i386/freebsd64.h
+@@ -41,4 +41,5 @@
+         %{rdynamic:-export-dynamic} \
+ 	-dynamic-linker %(fbsd_dynamic_linker) } \
+     %{static:-Bstatic}} \
++  %{!static:" ELF_HASH_STYLE "-rpath @PREFIX@/gcc-aux/lib} \
+   %{symbolic:-Bsymbolic}"
 --- gcc/config/i386/netbsd-elf.h.orig
 +++ gcc/config/i386/netbsd-elf.h
-@@ -119,3 +119,9 @@
+@@ -38,7 +38,8 @@
+ /* Provide a LINK_SPEC appropriate for a NetBSD/i386 ELF target.  */
+ 
+ #undef LINK_SPEC
+-#define LINK_SPEC NETBSD_LINK_SPEC_ELF
++#define LINK_SPEC NETBSD_LINK_SPEC_ELF \
++"%{!static:-rpath @PREFIX@/gcc-aux/lib}"
+ 
+ #define NETBSD_ENTRY_POINT "__start"
+ 
+@@ -119,3 +120,9 @@
  #define DEFAULT_PCC_STRUCT_RETURN 1
  
  #define HAVE_ENABLE_EXECUTE_STACK
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 6 Frederic Culot freebsd_committer freebsd_triage 2012-08-09 07:29:57 UTC
State Changed
From-To: open->closed

Committed. Thanks!