diff --git a/src/cmd/builtin/Mamfile b/src/cmd/builtin/Mamfile index 71118b5cd185..67ecd21388ca 100644 --- a/src/cmd/builtin/Mamfile +++ b/src/cmd/builtin/Mamfile @@ -112,7 +112,7 @@ make install virtual exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""builtin"\" -DCMD_STANDALONE=b_pty -c pty.c done pty.o bind -lutil dontcare - exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o pty pty.o ${mam_libutil} ${mam_libast} -lm ${mam_libcmd} + exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o pty pty.o ${mam_libutil} ${mam_libast} ${mam_libcmd} done pty make ${INSTALLROOT}/bin exec - mkdir -p ${INSTALLROOT}/bin diff --git a/src/cmd/builtin/features/pty b/src/cmd/builtin/features/pty index a7c20d306325..73a44e4733e7 100644 --- a/src/cmd/builtin/features/pty +++ b/src/cmd/builtin/features/pty @@ -11,8 +11,7 @@ lib openpty,_getpty,ptsname -lutil lib grantpt,unlockpt,posix_openpt stdlib.h lib cfmakeraw termios.h -# try once with -lm, once without -tst - -lm - - output{ +tst output{ #include #if _lib_ptsname #include @@ -51,11 +50,8 @@ tst - -lm - - output{ return 0; } }end fail{ - case ${_features_pty_TRIEDONCE-no} in - no) _features_pty_TRIEDONCE=yes ;; - *) echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 - exit 1 ;; - esac + echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2 + exit 1 }end extern _getpty char* (int*, int, mode_t, int) diff --git a/src/cmd/ksh93/Mamfile b/src/cmd/ksh93/Mamfile index fe3562f9a5b9..3e4fb7078806 100644 --- a/src/cmd/ksh93/Mamfile +++ b/src/cmd/ksh93/Mamfile @@ -23,17 +23,16 @@ make install virtual bind -ldll bind -lcmd bind -last - bind -lm dontcare bind -lnsl dontcare make shell.req prev ${INSTALLROOT}/bin/mkreq - exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : shell dll cmd ast m jobs i socket nsl secdb network + exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : shell dll cmd ast jobs i socket nsl secdb network done shell.req make shopt.h notrace implicit make FEATURE/options implicit prev features/options prev shell.req - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/options + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/options done FEATURE/options prev SHOPT.sh prev Mamfile @@ -108,13 +107,13 @@ make install virtual make sh/pmain.c make FEATURE/externs implicit prev features/externs - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/externs + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/externs done FEATURE/externs make include/shell.h implicit make include/fault.h implicit make FEATURE/sigfeatures implicit prev features/sigfeatures - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/sigfeatures + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/sigfeatures done FEATURE/sigfeatures make ${PACKAGE_ast_INCLUDE}/sfio.h implicit prev ${PACKAGE_ast_INCLUDE}/sfio_s.h implicit @@ -247,7 +246,7 @@ make install virtual prev include/shtable.h make FEATURE/dynamic implicit prev features/dynamic - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/dynamic + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/dynamic prev ${PACKAGE_ast_INCLUDE}/dlldefs.h done FEATURE/dynamic prev ${PACKAGE_ast_INCLUDE}/option.h @@ -307,17 +306,17 @@ make install virtual make include/terminal.h implicit make FEATURE/ttys implicit prev features/ttys - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/ttys + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/ttys done FEATURE/ttys done include/terminal.h prev ${PACKAGE_ast_INCLUDE}/sig.h make FEATURE/locale implicit prev features/locale - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/locale + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/locale done FEATURE/locale make FEATURE/cmds implicit prev features/cmds - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/cmds + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/cmds done FEATURE/cmds done include/edit.h prev include/builtins.h @@ -340,7 +339,7 @@ make install virtual prev ${PACKAGE_ast_INCLUDE}/times.h make FEATURE/time implicit prev features/time - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/time + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/time make ${PACKAGE_ast_INCLUDE}/times.h implicit dontcare prev ${PACKAGE_ast_INCLUDE}/ast_time.h implicit dontcare prev ${PACKAGE_ast_INCLUDE}/ast.h @@ -436,7 +435,7 @@ make install virtual make bltins/sleep.c make FEATURE/poll implicit prev features/poll - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/poll + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/poll done FEATURE/poll prev FEATURE/time prev include/builtins.h @@ -492,7 +491,7 @@ make install virtual make include/ulimit.h implicit make FEATURE/rlimits implicit prev features/rlimits - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/rlimits + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/rlimits done FEATURE/rlimits prev FEATURE/time done include/ulimit.h @@ -1031,7 +1030,7 @@ make install virtual make features/math.sh prev data/math.tab implicit done features/math.sh - exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} -lm : run features/math.sh ${PACKAGEROOT}/src/cmd/ksh93/data/math.tab + exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libnsl} : run features/math.sh ${PACKAGEROOT}/src/cmd/ksh93/data/math.tab prev ${PACKAGE_ast_INCLUDE}/ast_standards.h implicit make ${INSTALLROOT}/src/lib/libast/FEATURE/float implicit prev ${INSTALLROOT}/src/lib/libast/FEATURE/standards implicit @@ -1163,7 +1162,7 @@ make install virtual exec - (ranlib libshell.a) >/dev/null 2>&1 || true done libshell.a bind -lshell - exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o ksh pmain.o ${mam_libshell} ${mam_libnsl} ${mam_libast} -lm + exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o ksh pmain.o ${mam_libshell} ${mam_libnsl} ${mam_libast} done ksh make shcomp make shcomp.o @@ -1179,7 +1178,7 @@ make install virtual exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSH_DICT=${SH_DICT} -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -c sh/shcomp.c done shcomp.o prev ksh - exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o shcomp shcomp.o ${mam_libshell} ${mam_libnsl} ${mam_libast} -lm + exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o shcomp shcomp.o ${mam_libshell} ${mam_libnsl} ${mam_libast} done shcomp make shell virtual prev libshell.a diff --git a/src/lib/libast/Mamfile b/src/lib/libast/Mamfile index 6842b798686d..181f51e61439 100644 --- a/src/lib/libast/Mamfile +++ b/src/lib/libast/Mamfile @@ -272,6 +272,7 @@ make install virtual note * generate initial ast.req note * prev ${INSTALLROOT}/bin/mkreq + exec - set -o errexit exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : ast iconv w note * note * some systems move -lc routines to -lm; see astmath.c for details @@ -281,13 +282,15 @@ make install virtual prev std/endian.h done port/astmath.c exec - X=1 - exec - for N in 1 2 3 4 5 6 8 + exec - for N in 1 2 3 4 5 6 7 8 exec - do if ${CC} ${CCLDFLAGS} -DN=$N -DIS ${mam_cc_FLAGS} ${CCFLAGS} -I. -Istd ${LDFLAGS} -o astmath.exe port/astmath.c 2>/dev/null exec - then : implicit math function N=$N : exec - elif ${CC} ${CCLDFLAGS} -DN=$N -DIS ${mam_cc_FLAGS} ${CCFLAGS} -I. -Istd ${LDFLAGS} -o astmath.exe port/astmath.c -lm 2>/dev/null exec - then : math function N=$N requires -lm : exec - X=0 exec - break + exec - else : ERROR: astmath.c fails to compile or link, even with -lm : + exec - exit 1 exec - fi exec - done exec - ${STDRM} -rf astmath.exe* @@ -295,7 +298,8 @@ make install virtual done astmath.out prev FEATURE/aso exec - sed -e '/^#define _REQ_/!d' -e 's/#define _REQ_\([a-z0-9_]*\).*/ -l\1/' FEATURE/aso >> ast.req - exec - case $(${STDCAT} astmath.out) in + exec - read no_libm_needed > ast.req ;; exec - *) touch ast.req ;; exec - esac @@ -4989,6 +4993,7 @@ make install virtual exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I${INSTALLROOT}/include/ast -D_PACKAGE_ast -c ${PACKAGEROOT}/src/cmd/INIT/mamake.c done mamake.o bind -last + exec - set -o errexit exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L${INSTALLROOT}/lib} -o mamake mamake.o ${mam_libast} note * note * We purposely do not have a make target of ${INSTALLROOT}/bin/mamake here; diff --git a/src/lib/libast/port/astmath.c b/src/lib/libast/port/astmath.c index 917a5de2d467..5e6afe47025c 100644 --- a/src/lib/libast/port/astmath.c +++ b/src/lib/libast/port/astmath.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * @@ -20,27 +20,33 @@ /* * used to test if -last requires -lm * - * arch -last -lm - * ---- ----- --- - * linux.sparc sfdlen,sfputd frexp,ldexp + * This program is compiled and linked from a probe script in libast/Mamfile + * but never actually run. It is only used to check if linking succeeds + * without or with -lm. + * + * For that test to work correctly, we must work around compiler optimization. + * The rand() calls are to stop the result from being considered known at + * compile time, which would cause modern compilers to optimize out the probe + * calls, which would in turn cause linking to succeed where it shouldn't. */ #if N >= 8 #define _ISOC99_SOURCE 1 #endif +#include #include int main(void) { #if N & 1 - long double value = 0; + long double value = rand(); #else - double value = 0; + double value = rand(); #endif #if N < 5 - int exp = 0; + int exp = rand(); #endif #if N == 1