From 5f1533f11b0287e128f42294609bbbdcebb1eb88 Mon Sep 17 00:00:00 2001 From: joerg Date: Fri, 14 Nov 2008 14:04:12 +0000 Subject: Improve AIX/XLC support based on discussions with Jens Rehsack: - Add cc_r/xlc_r wrapper using the same rules as xlc itself. It is used for example by Perl. - Improve the RPATH emulation: - Always set -blibpath, use /usr/lib:/lib as default - If -blibpath is exlicitly given, add to the default - Additionally append any -Wl,-rpath given. --- mk/compiler/xlc.mk | 9 ++++++++- mk/wrapper/bsd.wrapper.mk | 10 +++++++++- mk/wrapper/cmd-sink-aix-cc | 23 +++++++++++++++++++---- mk/wrapper/cmd-sink-aix-ld | 18 ++++++++++++++---- mk/wrapper/cmd-sink-aix-xlc | 22 ++++++++++++++++++---- 5 files changed, 68 insertions(+), 14 deletions(-) (limited to 'mk') diff --git a/mk/compiler/xlc.mk b/mk/compiler/xlc.mk index bf352ee7818..920726c9117 100644 --- a/mk/compiler/xlc.mk +++ b/mk/compiler/xlc.mk @@ -1,4 +1,4 @@ -# $NetBSD: xlc.mk,v 1.17 2008/02/07 20:59:05 rillig Exp $ +# $NetBSD: xlc.mk,v 1.18 2008/11/14 14:04:12 joerg Exp $ # # Copyright (c) 2005 The NetBSD Foundation, Inc. # All rights reserved. @@ -82,6 +82,13 @@ _ALIASES.CXX= c++ xlc++ CXXPATH= ${XLCBASE}/bin/xlc++ PKG_CXX:= ${_XLC_CXX} .endif +.if exists(${XLCBASE}/bin/xlc) +_XLC_VARS+= CC_R +_XLC_CC_R= ${_XLC_DIR}/bin/cc_r +_ALIASES.CC_R= cc_r xlc_r +CC_RPATH= ${XLCBASE}/bin/xlc_r +PKG_CC_R:= ${_XLC_CC_R} +.endif _COMPILER_STRIP_VARS+= ${_XLC_VARS} _COMPILER_RPATH_FLAG= -Wl,-R _LINKER_RPATH_FLAG= -R diff --git a/mk/wrapper/bsd.wrapper.mk b/mk/wrapper/bsd.wrapper.mk index 19789cf51fd..38d956359c0 100644 --- a/mk/wrapper/bsd.wrapper.mk +++ b/mk/wrapper/bsd.wrapper.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.wrapper.mk,v 1.78 2008/11/06 21:34:16 joerg Exp $ +# $NetBSD: bsd.wrapper.mk,v 1.79 2008/11/14 14:04:12 joerg Exp $ # # Copyright (c) 2005 The NetBSD Foundation, Inc. # All rights reserved. @@ -139,6 +139,11 @@ WRAPPEES+= IMAKE .endif WRAPPEES+= LD +.if !empty(PKGSRC_COMPILER:Mxlc) && ${OPSYS} == "AIX" +CC_R?= ${_XLC_DIR}/bin/cc_r +WRAPPEES+= CC_R +.endif + _WRAPPEE_UNIQUE_CMDS= # empty .for _wrappee_ in ${WRAPPEES} _WRAPPEES+= ${_wrappee_} @@ -283,6 +288,7 @@ _WRAP_TRANSFORM.CPP= ${_WRAP_TRANSFORM.CC} .if !empty(PKGSRC_COMPILER:Mxlc) . if ${OPSYS} == "AIX" _WRAP_CMD_SINK.CC= ${WRAPPER_TMPDIR}/cmd-sink-aix-xlc +_WRAP_CMD_SINK.CC_R= ${WRAPPER_TMPDIR}/cmd-sink-aix-xlc _WRAP_CMD_SINK.CXX= ${_WRAP_CMD_SINK.CC} _WRAP_CMD_SINK.LD= ${_WRAP_CMD_SINK.CC} . elif ${OPSYS} == "Darwin" @@ -346,7 +352,9 @@ _WRAP_CMD_SINK.CC?= ${WRAPPER_TMPDIR}/cmd-sink-aix-cc _WRAP_CMD_SINK.CXX?= ${_WRAP_CMD_SINK.CC} _WRAP_CMD_SINK.LD?= ${WRAPPER_TMPDIR}/cmd-sink-aix-ld _WRAP_CACHE_BODY.CC?= ${WRAPPER_TMPDIR}/cache-body-aix-cc +_WRAP_CACHE_BODY.CC_R?= ${WRAPPER_TMPDIR}/cache-body-aix-cc _WRAP_TRANSFORM.CC?= ${WRAPPER_TMPDIR}/transform-aix-cc +_WRAP_TRANSFORM.CC_R?= ${WRAPPER_TMPDIR}/transform-aix-cc _WRAP_CACHE_BODY.CXX?= ${_WRAP_CACHE_BODY.CC} _WRAP_TRANSFORM.CXX?= ${_WRAP_TRANSFORM.CC} .elif ${OPSYS} == "IRIX" diff --git a/mk/wrapper/cmd-sink-aix-cc b/mk/wrapper/cmd-sink-aix-cc index c1d6df325a2..8dcb2679e8c 100644 --- a/mk/wrapper/cmd-sink-aix-cc +++ b/mk/wrapper/cmd-sink-aix-cc @@ -1,4 +1,4 @@ -# $NetBSD: cmd-sink-aix-cc,v 1.2 2005/05/16 17:54:51 jlam Exp $ +# $NetBSD: cmd-sink-aix-cc,v 1.3 2008/11/14 14:04:12 joerg Exp $ # # Copyright (c) 2005 The NetBSD Foundation, Inc. # All rights reserved. @@ -36,12 +36,23 @@ # Empty out the command buffer and build up the command line in $cmd. blibpath= +orig_blibpath= dynamic= while ! queue_is_empty cmdbuf; do pop_queue cmdbuf arg $debug_log $wrapperlog " (cmd-sink-aix-cc) pop: $arg" case $arg in + -blibpath:*) + orig_blibpath=${arg#-blibpath:} + $debug_log $wrapperlog " (cmd-sink-aix-ld) drop: $dir [setting orig_blibpath]" + dynamic=yes + ;; + -Wl,-blibpath:*) + orig_blibpath=${arg#-Wl,-blibpath:} + $debug_log $wrapperlog " (cmd-sink-aix-ld) drop: $dir [setting orig_blibpath]" + dynamic=yes + ;; ############################################################## # AIX ld(1) doesn't support -Wl,-rpath,* but accumulate them # into a path collection we can later append to command line @@ -70,11 +81,15 @@ while ! queue_is_empty cmdbuf; do done # AIX ld(1) uses -blibpath to set the runtime library search path. +arg="-Wl,-blibpath:/usr/usr/lib:/lib" +if $test -n "$orig_blibpath"; then + arg="$arg:$orig_blibpath" +fi if $test -n "$blibpath"; then - arg="-Wl,-blibpath:/lib:/usr/lib:$blibpath" - $debug_log $wrapperlog " (cmd-sink-aix-cc) pop: $arg" - . $buildcmd + arg="$arg:$blibpath" fi +$debug_log $wrapperlog " (cmd-sink-aix-cc) pop: $arg" +. $buildcmd # If we are dynamically linking, make sure the runtime linker is used. if $test -n "$dynamic"; then diff --git a/mk/wrapper/cmd-sink-aix-ld b/mk/wrapper/cmd-sink-aix-ld index e721b5b3101..a7bd4b3153f 100644 --- a/mk/wrapper/cmd-sink-aix-ld +++ b/mk/wrapper/cmd-sink-aix-ld @@ -1,4 +1,4 @@ -# $NetBSD: cmd-sink-aix-ld,v 1.2 2005/05/16 17:54:51 jlam Exp $ +# $NetBSD: cmd-sink-aix-ld,v 1.3 2008/11/14 14:04:12 joerg Exp $ # # Copyright (c) 2004 The NetBSD Foundation, Inc. # All rights reserved. @@ -35,6 +35,7 @@ # POSSIBILITY OF SUCH DAMAGE. # Empty out the command buffer and build up the command line in $cmd. +orig_blibpath= blibpath= dynamic= @@ -42,6 +43,11 @@ while ! queue_is_empty cmdbuf; do pop_queue cmdbuf arg $debug_log $wrapperlog " (cmd-sink-aix-ld) pop: $arg" case $arg in + -blibpath:*) + orig_blibpath=${arg#-blibpath:} + $debug_log $wrapperlog " (cmd-sink-aix-ld) drop: $dir [setting orig_blibpath]" + dynamic=yes + ;; ############################################################## # AIX ld(1) doesn't support -Wl,-rpath,* but accumulate them # into a path collection we can later append to command line @@ -70,11 +76,15 @@ while ! queue_is_empty cmdbuf; do done # AIX ld(1) uses -blibpath to set the runtime library search path. +arg="-blibpath:/usr/usr/lib:/lib" +if $test -n "$orig_blibpath"; then + arg="$arg:$orig_blibpath" +fi if $test -n "$blibpath"; then - arg="-blibpath:/lib:/usr/lib:$blibpath" - $debug_log $wrapperlog " (cmd-sink-aix-ld) pop: $arg" - . $buildcmd + arg="$arg:$blibpath" fi +$debug_log $wrapperlog " (cmd-sink-aix-ld) pop: $arg" +. $buildcmd # If we are dynamically linking, make sure the runtime linker is used. if $test -n "$dynamic"; then diff --git a/mk/wrapper/cmd-sink-aix-xlc b/mk/wrapper/cmd-sink-aix-xlc index 65672eb57ee..cddf75ebc04 100644 --- a/mk/wrapper/cmd-sink-aix-xlc +++ b/mk/wrapper/cmd-sink-aix-xlc @@ -1,4 +1,4 @@ -# $NetBSD: cmd-sink-aix-xlc,v 1.4 2007/10/05 18:19:45 joerg Exp $ +# $NetBSD: cmd-sink-aix-xlc,v 1.5 2008/11/14 14:04:12 joerg Exp $ # # Copyright (c) 2004 The NetBSD Foundation, Inc. # All rights reserved. @@ -36,10 +36,19 @@ # Empty out the command buffer and build up the command line in $cmd. blibpath= +orig_blibpath= while ! queue_is_empty cmdbuf; do pop_queue cmdbuf arg $debug_log $wrapperlog " (cmd-sink-aix-xlc) pop: $arg" case $arg in + -blibpath:*) + orig_blibpath=${arg#-blibpath:} + $debug_log $wrapperlog " (cmd-sink-aix-ld) drop: $dir [setting orig_blibpath]" + ;; + -Wl,-blibpath:*) + orig_blibpath=${arg#-Wl,-blibpath:} + $debug_log $wrapperlog " (cmd-sink-aix-ld) drop: $dir [setting orig_blibpath]" + ;; ############################################################## # AIX xlC doesn't support -Wl,-rpath,* but accumulate them # into a path collection we can later append to command line @@ -67,11 +76,16 @@ while ! queue_is_empty cmdbuf; do done # AIX xlc uses -blibpath to set the runtime library search path. +arg="-Wl,-blibpath:/usr/usr/lib:/lib" +if $test -n "$orig_blibpath"; then + arg="$arg:$orig_blibpath" +fi if $test -n "$blibpath"; then - arg="-blibpath:$blibpath" - $debug_log $wrapperlog " (cmd-sink-aix-xlc) pop: $arg" - . $buildcmd + arg="$arg:$blibpath" fi +$debug_log $wrapperlog " (cmd-sink-aix-xlc) pop: $arg" +. $buildcmd + # Force dynamic linkage on AIX to get preference of dynamic libraries # over library archives. if $test "$dont_link" != "yes"; then -- cgit v1.2.3