summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-05-10 04:53:29 +0100
committerPádraig Brady <P@draigBrady.com>2014-05-21 18:29:38 +0100
commit1ab31d1ec1635ae0764604a8bf61e11851a63a45 (patch)
tree54b5f8dccbde4e512a394ff8b42e6635209ea573 /src
parent7a63d6395ac117b753a18468a9b3f5ed95d176d4 (diff)
downloadcoreutils-1ab31d1ec1635ae0764604a8bf61e11851a63a45.tar.xz
stdbuf: support compilers other than __GNUC__
__SUNPRO_C >= 0x590 /*12.0*/ supports __attribute((constructor)) required by stdbuf, so use a more direct check for this. Note ensure that --libexecdir is set to the appropriate install location for libstdbuf.so so that stdbuf works when installed on the system like it does when running tests in the build directory. * configure.ac (stdbuf_supported): Use a test prog to determine support. * src/libstdbuf.c (stdbuf): Define appropriately for non GCC compilers, and provide early feedback (compilation warning) if trying to compile libstdbuf without the necessary support. * src/stdbuf.c (set_LD_PRELOAD): Add a note on having stdbuf look for libstdbuf.so in the default lib search path. * cfg.mk (sc_prohibit-gl-attributes): Adjust so we can exclude libstdbuf.so from prohibiting '__attribute', since we want this form to avoid silently eliding this required attribute on non GCC. Reported and tested by Rich Burridge.
Diffstat (limited to 'src')
-rw-r--r--src/libstdbuf.c3
-rw-r--r--src/stdbuf.c12
2 files changed, 13 insertions, 2 deletions
diff --git a/src/libstdbuf.c b/src/libstdbuf.c
index 88321e9e4..1281b9de7 100644
--- a/src/libstdbuf.c
+++ b/src/libstdbuf.c
@@ -127,7 +127,8 @@ apply_mode (FILE *stream, const char *mode)
}
}
-__attribute__ ((constructor)) static void
+/* Use __attribute to avoid elision of __attribute__ on SUNPRO_C etc. */
+static void __attribute ((constructor))
stdbuf (void)
{
char *e_mode = getenv ("_STDBUF_E");
diff --git a/src/stdbuf.c b/src/stdbuf.c
index 270881bf5..c648fc5d0 100644
--- a/src/stdbuf.c
+++ b/src/stdbuf.c
@@ -195,7 +195,17 @@ set_LD_PRELOAD (void)
However we want the lookup done for the exec'd command not stdbuf.
Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR
- rather than to LIBDIR. */
+ rather than to LIBDIR.
+
+ Note we could add "" as the penultimate item in the following list
+ to enable searching for libstdbuf.so in the default system lib paths.
+ However that would not indicate an error if libstdbuf.so was not found.
+ Also while this could support auto selecting the right arch in a multilib
+ environment, what we really want is to auto select based on the arch of the
+ command being run, rather than that of stdbuf itself. This is currently
+ not supported due to the unusual need for controlling the stdio buffering
+ of programs that are a different architecture to the default on the
+ system (and that of stdbuf itself). */
char const *const search_path[] = {
program_path,
PKGLIBEXECDIR,