From 4982d4ebc3bd4924d73f2f2ad584309e9ec97435 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:52:02 -0700 Subject: all: update build scripts to fix AIX XL/C compatibility --- bin/9c | 19 ++++++++++++++++++- bin/9l | 13 +++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/9c b/bin/9c index 0f836d24..320a1634 100755 --- a/bin/9c +++ b/bin/9c @@ -82,6 +82,23 @@ useclang() cflags="$ngflags -g" } +usexlc() +{ + cc=${CC9:-xlc_r} + ngflags=" \ + -c \ + -O0 \ + -qmaxmem=-1 \ + -qsuppress=1506-236 \ + -qsuppress=1506-358 \ + -qsuppress=1500-010 \ + -qsuppress=1506-224 \ + -qsuppress=1506-1300 \ + -qsuppress=1506-342 \ + " + cflags="$ngflags -g -qfullpath" +} + tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" case "$tag" in *DragonFly*gcc*|*BSD*gcc*) usegcc ;; @@ -120,7 +137,7 @@ case "$tag" in cflags="$ngflags -g" cflags="$cflags -D__sun__ -D__${s}__" ;; -*AIX*) usegcc +*AIX*) usexlc cflags="$ngflags -g -D__AIX__" ;; *) diff --git a/bin/9l b/bin/9l index a10aab72..398adbd8 100755 --- a/bin/9l +++ b/bin/9l @@ -61,8 +61,9 @@ case "$tag" in esac ;; *AIX*) - ld=${CC9:-gcc} - nmflags="-B" + ld="${CC9:-xlc_r} -g -O0" + nmflags="-A -B" + extralibs="$extralibs -lpthread" ;; *) echo do not know how to link on "$tag" 1>&2 @@ -113,8 +114,8 @@ then then a=` nm $nmflags $ofiles | - grep '__p9l_autolib_[a-zA-Z0-9+-]*$' | - sed 's/.*__p9l_autolib_//' | + grep '__p9l_autolib_[a-zA-Z0-9+-]*' | + sed 's/.*__p9l_autolib_//; s/:.*//' | sort -u ` for i in $a @@ -144,8 +145,8 @@ then do b=` nm $lpath/lib$i.a 2>/dev/null | - grep '__p9l_autolib_[a-zA-Z0-9+-]*$' | - sed 's/.*__p9l_autolib_//' | + grep '__p9l_autolib_[a-zA-Z0-9+-]*' | + sed 's/.*__p9l_autolib_//; s/:.*//' | sort -u | egrep -v '^(thread|draw)$' ` -- cgit v1.2.3 From 9444b8e4bc847f8fd9d02466976b962288cedf31 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 20:07:52 -0400 Subject: 9c, 9l: accept CC9FLAGS from config Also, if CC9FLAGS includes -fsanitize=address (ASAN), predefine PLAN9PORT_ASAN for use by programs that need to know (mainly libthread). The 9c script used to have a variable called ngflags, which was ccflags except -g (ng stood for "no g"), but nothing needs it split out anymore, so simplify to just ccflags. --- bin/9c | 34 +++++++++++++++++++++++----------- bin/9l | 14 +++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) (limited to 'bin') diff --git a/bin/9c b/bin/9c index 320a1634..dd899293 100755 --- a/bin/9c +++ b/bin/9c @@ -4,7 +4,7 @@ test -f $PLAN9/config && . $PLAN9/config usegcc() { cc=${CC9:-gcc} - ngflags=" \ + cflags=" \ -O2 \ -c \ -Wall \ @@ -24,7 +24,12 @@ usegcc() " # want to put -fno-optimize-sibling-calls here but # that option only works with gcc3+ it seems - cflags="$ngflags -ggdb" + cflags="$cflags -ggdb" + cflags="$cflags $CC9FLAGS" + case "$cflags" in + *sanitize=address*) + cflags="$cflags -DPLAN9PORT_ASAN" + esac } quiet() @@ -60,7 +65,7 @@ quiet() useclang() { cc=${CC9:-clang} - ngflags=" \ + cflags=" \ -O2 \ -c \ -Wall \ @@ -79,13 +84,19 @@ useclang() -fsigned-char \ -fno-caret-diagnostics \ " - cflags="$ngflags -g" + cflags="$cflags -g" + cflags="$cflags $CC9FLAGS" + + case "$cflags" in + *sanitize=address*) + cflags="$cflags -DPLAN9PORT_ASAN" + esac } usexlc() { cc=${CC9:-xlc_r} - ngflags=" \ + cflags=" \ -c \ -O0 \ -qmaxmem=-1 \ @@ -96,7 +107,8 @@ usexlc() -qsuppress=1506-1300 \ -qsuppress=1506-342 \ " - cflags="$ngflags -g -qfullpath" + cflags="$cflags -g -qfullpath" + cflags="$cflags $CC9FLAGS" } tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" @@ -105,14 +117,14 @@ case "$tag" in *DragonFly*clang|*BSD*clang*) useclang ;; *Darwin-x86_64*) useclang - cflags="$ngflags -g3 -m64" + cflags="$cflags -g3 -m64" ;; *Darwin*clang*) useclang - cflags="$ngflags -g3 -m32" + cflags="$cflags -g3 -m32" ;; *Darwin*) usegcc - cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; + cflags="$cflags -g3 -no-cpp-precomp -m32" ;; *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; *Linux*) usegcc case "${CC9:-gcc}" in @@ -134,11 +146,11 @@ case "$tag" in u=`uname` v=`uname -r` s=`echo $u$v | tr '. ' '__'` - cflags="$ngflags -g" + cflags="$cflags -g" cflags="$cflags -D__sun__ -D__${s}__" ;; *AIX*) usexlc - cflags="$ngflags -g -D__AIX__" + cflags="$cflags -g -D__AIX__" ;; *) echo 9c does not know how to compile on "$tag" 1>&2 diff --git a/bin/9l b/bin/9l index 398adbd8..875e103a 100755 --- a/bin/9l +++ b/bin/9l @@ -12,29 +12,29 @@ extralibs="-lm" tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}" case "$tag" in *DragonFly*|*BSD*) - ld=${CC9:-gcc} + ld="${CC9:-gcc} $CC9FLAGS" userpath=true extralibs="$extralibs -lutil" ;; *OSF1*) - ld=${CC9:-cc} + ld="${CC9:-cc} $CC9FLAGS" userpath=true extralibs="$extralibs -lutil" nmflags="-B" ;; *Linux*) - ld=${CC9:-gcc} + ld="${CC9:-gcc} $CC9FLAGS" userpath=true extralibs="$extralibs -lutil -lresolv -lpthread" ;; *Darwin*x86_64*) - ld="${CC9:-gcc} -m64" + ld="${CC9:-gcc} -m64 $CC9FLAGS" ;; *Darwin*) - ld="${CC9:-gcc} -m32" + ld="${CC9:-gcc} -m32 $CC9FLAGS" ;; *SunOS*) - ld="${CC9:-cc} -g" + ld="${CC9:-cc} -g $CC9FLAGS" extralibs="$extralibs -lrt -lpthread -lsocket -lnsl" # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH for i in "$libsl $@" @@ -61,7 +61,7 @@ case "$tag" in esac ;; *AIX*) - ld="${CC9:-xlc_r} -g -O0" + ld="${CC9:-xlc_r} -g -O0 $CC9FLAGS" nmflags="-A -B" extralibs="$extralibs -lpthread" ;; -- cgit v1.2.3 From 53bf1f1ccf9a6fee9437649216ac047f80590fae Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 18 May 2020 12:20:48 -0700 Subject: 9l: xlc_r automatically adds -lpthread. --- bin/9l | 1 - 1 file changed, 1 deletion(-) (limited to 'bin') diff --git a/bin/9l b/bin/9l index 875e103a..b4f91584 100755 --- a/bin/9l +++ b/bin/9l @@ -63,7 +63,6 @@ case "$tag" in *AIX*) ld="${CC9:-xlc_r} -g -O0 $CC9FLAGS" nmflags="-A -B" - extralibs="$extralibs -lpthread" ;; *) echo do not know how to link on "$tag" 1>&2 -- cgit v1.2.3 From fa157263c8f510318f1f119a2d4843281e506eba Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:38:54 -0400 Subject: 9c: fix tab --- bin/9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/9c b/bin/9c index dd899293..a22a0a08 100755 --- a/bin/9c +++ b/bin/9c @@ -149,7 +149,7 @@ case "$tag" in cflags="$cflags -g" cflags="$cflags -D__sun__ -D__${s}__" ;; -*AIX*) usexlc +*AIX*) usexlc cflags="$cflags -g -D__AIX__" ;; *) -- cgit v1.2.3 From 799f330f6de8ff65a7bdf7e0d1b12cd3c10981ba Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 30 May 2020 06:35:27 -0400 Subject: osxvers: use swvers -productVersion to skip one awk call Fixes #406. Suggested by nms42. --- bin/osxvers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/osxvers b/bin/osxvers index 4af44da2..6ebeb11f 100755 --- a/bin/osxvers +++ b/bin/osxvers @@ -3,5 +3,5 @@ u=`uname` case "$u" in Darwin) - sw_vers | awk '$1 == "ProductVersion:" {print $2}' | awk -F. '{printf("CFLAGS=$CFLAGS -DOSX_VERSION=%d%02d%02d\n", $1, $2, $3)}' + sw_vers -productVersion | awk -F. '{printf("CFLAGS=$CFLAGS -DOSX_VERSION=%d%02d%02d\n", $1, $2, $3)}' esac -- cgit v1.2.3