mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
iffe: include OS standards macros in iffe tests by default
In iffe tests, some C functions are found in system libraries, but then are not declared by the system headers on some systems because the expected standards macros aren't defined, causing the system headers to hide the function declarations. This may cause warnings about invalid implicit function declarations in some tests (which only show up if you export IFFEFLAGS=-d1), but may also cause false negative test results. The iffe tests should be given the same environment that their test results are going to be used in. libast's first-run and most central feature test, 'standards', figures out what standards macros need to be used on the current system to get the system headers to declare the expected functionality. All code that links to libast depends on the header generated by this feature test. So iffe should use this result for the tests as well, as soon as it's available (which is early in libast's compilation cycle). Concrete example: on Cygwin, in src/cmd/builtin/features/pty, the 'lib ptsname' test detects ptsname(3) in the system library, but the output{...}end block that uses the _lib_ptsname feature test result throws an 'implicit function definition' warning because Cygwin's stdlib.h does not define this function without the appropriate standards macros being defined first. src/cmd/INIT/iffe.sh: - If ${INSTALLROOT}/src/lib/libast/FEATURE/standards is available, incorporate it directly into iffe's own block of compiler massaging macros. Do not use #include as the necessary -I flags are not added for every test. - Centrally define the iffe version once, not twice. - Update and tweak getopts self-documentation (iffe --man). - While we're here, add macOS/Darwin's DYLD_LIBRARY_PATH to the supported dynamic library search variables. On macOS, this is normally disabled by System Integrity Protection, plus this distribution uses static libraries at build time, so this is for completeness' sake and not much else. This was ported from @lkujaw's fork: https://github.com/lkujaw/ast/commit/48ff05442994 (thanks to @JohnoKing for pointing it out). src/lib/libast/features/standards: - Add a comment. This is to update the file's timestamp, ensuring that everything will be recompiled after this commit.
This commit is contained in:
parent
c842f46bbd
commit
7fb814e186
2 changed files with 17 additions and 6 deletions
|
@ -32,7 +32,7 @@ AIX) unset LIBPATH ;;
|
|||
esac
|
||||
|
||||
command=iffe
|
||||
version=2021-02-03 # update in USAGE too #
|
||||
version=2021-12-06
|
||||
|
||||
compile() # $cc ...
|
||||
{
|
||||
|
@ -660,7 +660,8 @@ ifs=${IFS-'
|
|||
in=
|
||||
includes=
|
||||
intrinsic=
|
||||
libpaths="LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LIBPATH SHLIB_PATH"
|
||||
libpaths="DYLD_LIBRARY_PATH LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LIBPATH SHLIB_PATH"
|
||||
DYLD_LIBRARY_PATH_default=:/lib:/usr/lib
|
||||
LD_LIBRARY_PATH_default=:/lib:/usr/lib
|
||||
LD_LIBRARYN32_PATH_default=:/lib32:/usr/lib32
|
||||
LD_LIBRARY64_PATH_default=:/lib64:/usr/lib64
|
||||
|
@ -754,7 +755,7 @@ set=
|
|||
case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
|
||||
0123) USAGE=$'
|
||||
[-?
|
||||
@(#)$Id: iffe (ksh 93u+m) 2021-02-03 $
|
||||
@(#)$Id: iffe (ksh 93u+m) '${version}$' $
|
||||
]
|
||||
[-author?Glenn Fowler <gsf@research.att.com>]
|
||||
[-author?Phong Vo <kpv@research.att.com>]
|
||||
|
@ -897,8 +898,12 @@ case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
|
|||
[+ ?#define _END_EXTERNS_]
|
||||
[+ ?#endif]
|
||||
[+ ?#define _NIL_(x) ((x)0)]
|
||||
[+ ?#include <stdio.h>]
|
||||
[+ ?#include <stdio.h> /* unless changed using the "stdio" option */]
|
||||
}
|
||||
[+?In addition, if and when available, standards macros set as a result of the
|
||||
\bsrc/lib/libast/features/standards\b feature test are incorporated
|
||||
here, ensuring the compilation environment is consistent between the
|
||||
tests and the code that uses the test results.]
|
||||
[+?= \adefault\a may be specified for the \bkey\b, \blib\b, \bmac\b, \bmth\b
|
||||
and \btyp\b tests. If the test fails for \aarg\a then
|
||||
\b#define\b \aarg\a \adefault\a is emitted. \bkey\b accepts multiple
|
||||
|
@ -1079,8 +1084,8 @@ case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
|
|||
\bsh\b(1).]
|
||||
[+link?The block is compiled and linked (\bcc -o\b).]
|
||||
[+macro?The block is preprocessed (\bcc -E\b) and lines containing
|
||||
text bracketed by \b<<"\b ... \b">>\b (\aless-than less-than
|
||||
double-quote ... double-quote greater-than greater-than\a)
|
||||
text bracketed by \b<<"\b ... \b">>\b (\aless-than\a \aless-than\a
|
||||
\adouble-quote\a ... \adouble-quote\a \agreater-than\a \agreater-than\a)
|
||||
are copied to the output file with the brackets omitted.]
|
||||
[+no?If the test fails then the block text is copied to the
|
||||
output file. Deprecated: use { \bif\b \belif\b \belse\b
|
||||
|
@ -1364,6 +1369,11 @@ std='#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
|
|||
#define _END_EXTERNS_
|
||||
#endif
|
||||
#define _NIL_(x) ((x)0)'
|
||||
# To ensure the environment tested is the same as that used, add standards
|
||||
# compliance macros as probed by libast as soon as they are available.
|
||||
if test -f "${INSTALLROOT}/src/lib/libast/FEATURE/standards"
|
||||
then std=${std}${nl}`cat "${INSTALLROOT}/src/lib/libast/FEATURE/standards"`
|
||||
fi
|
||||
tst=
|
||||
ext="#include <stdio.h>"
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Disable default inclusion of <stdio.h> by setting stdio option to empty
|
||||
set stdio
|
||||
|
||||
# Flag systems that omit necessary definitions such as u_long
|
||||
|
|
Loading…
Reference in a new issue