In message <Pine.GSO.4.10.10309241029001.26896-100000_at_pcnet5.pcnet.com>, Daniel Eischen writes: >On Wed, 24 Sep 2003, Scott Long wrote: >> PTHREAD_LIBS is a great tool for the /usr/ports mechanism, but doesn't >> mean anything outside of that. > >That just meant it makes it easier to maintain ports so that >they are PTHREAD_LIBS compliant (they would break when linked). >I know it has no bearing on 3rd party stuff. Just to throw one further approach out on the table, below is a patch that makes gcc read from a file to determine what library to associate with the -pthread flag. It's a hack of course, and probably neither correct or optimal. If you want to make -pthread mean libkse, create an /etc/pthread.libs that looks like: -lc_r: -lkse -lc_r_p: -lkse_p I haven't been following the discussion in any detail - this is just another possibility that is worth mentioning as it could retain compatibility for users that want -pthread to mean use the default thread library. Ian Index: gcc.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/contrib/gcc/gcc.c,v retrieving revision 1.36 diff -u -r1.36 gcc.c --- gcc.c 11 Jul 2003 04:45:39 -0000 1.36 +++ gcc.c 24 Sep 2003 15:37:14 -0000 _at__at_ -331,6 +331,7 _at__at_ static const char *if_exists_spec_function PARAMS ((int, const char **)); static const char *if_exists_else_spec_function PARAMS ((int, const char **)); +static const char *thread_lib_override_spec_function PARAMS ((int, const char **)); /* The Specs Language _at__at_ -1440,6 +1441,7 _at__at_ { { "if-exists", if_exists_spec_function }, { "if-exists-else", if_exists_else_spec_function }, + { "thread-lib-override", thread_lib_override_spec_function }, { 0, 0 } }; _at__at_ -7335,4 +7337,46 _at__at_ return argv[0]; return argv[1]; +} + +/* thread-lib-override built-in spec function. + + Override a thread library according to /etc/pthread.libs */ + +static const char * +thread_lib_override_spec_function (argc, argv) + int argc; + const char **argv; +{ + static char buf[256]; + FILE *fp; + int n; + + /* Must have exactly one argument. */ + if (argc != 1) + return NULL; + + fp = fopen ("/etc/pthread.libs", "r"); + if (fp == NULL) + return argv[0]; + + while (fgets (buf, sizeof(buf), fp) != NULL) + { + n = strlen (buf); + while (n > 0 && buf[n - 1] == '\n') + buf[--n] = '\0'; + if (buf[0] == '#' || buf[0] == '\0') + continue; + n = strlen (argv[0]); + if (strncmp (buf, argv[0], n) != 0 || n >= sizeof (buf) || buf[n] != ':') + continue; + n++; + while (buf[n] != '\0' && isspace ((unsigned char)buf[n])) + n++; + fclose (fp); + + return &buf[n]; + } + fclose (fp); + return argv[0]; } Index: config/freebsd-spec.h =================================================================== RCS file: /dump/FreeBSD-CVS/src/contrib/gcc/config/freebsd-spec.h,v retrieving revision 1.14 diff -u -r1.14 freebsd-spec.h --- config/freebsd-spec.h 21 Sep 2003 07:59:16 -0000 1.14 +++ config/freebsd-spec.h 24 Sep 2003 15:38:11 -0000 _at__at_ -160,8 +160,8 _at__at_ #if __FreeBSD_version >= 500016 #define FBSD_LIB_SPEC " \ %{!shared: \ - %{!pg: %{pthread:-lc_r} -lc} \ - %{pg: %{pthread:-lc_r_p} -lc_p} \ + %{!pg: %{pthread:%:thread-lib-override(-lc_r)} -lc} \ + %{pg: %{pthread:%:thread-lib-override(-lc_r_p)} -lc_p} \ }" #else #define FBSD_LIB_SPEC " \Received on Wed Sep 24 2003 - 07:03:32 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:23 UTC