public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Tannenbaum, Barry M" <barry.m.tannenbaum@intel.com>
To: Thomas Schwinge <thomas@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"Iyer, Balaji V"	<balaji.v.iyer@intel.com>,
	"Zamyatin, Igor" <igor.zamyatin@intel.com>
Subject: RE: libcilkrts: Use AC_USE_SYSTEM_EXTENSIONS (was: Cilk Library)
Date: Wed, 01 Oct 2014 14:10:00 -0000	[thread overview]
Message-ID: <6B86B7F2A4026246AA81BA1ABF9756905C511EC7@fmsmsx107.amr.corp.intel.com> (raw)
In-Reply-To: <877g0jdh32.fsf@kepler.schwinge.homeip.net>

The problem arose in our internal build which is a (relatively) simple Makefile. Now that I know what AC_USE_SYSTEM_EXTENSIONS is doing I can adjust it accordingly.

Thanks.

  - Barry

-----Original Message-----
From: Thomas Schwinge [mailto:thomas@codesourcery.com] 
Sent: Wednesday, October 01, 2014 10:02 AM
To: Tannenbaum, Barry M
Cc: gcc-patches@gcc.gnu.org; Iyer, Balaji V; Zamyatin, Igor
Subject: Re: libcilkrts: Use AC_USE_SYSTEM_EXTENSIONS (was: Cilk Library)

Hi!

On Mon, 29 Sep 2014 20:13:38 +0200, I wrote:
> On Wed, 9 Oct 2013 18:32:11 +0000, "Iyer, Balaji V" <balaji.v.iyer@intel.com> wrote:
> > [libcilkrts]
> 
> Here is a patch to have libcilkrts use AC_USE_SYSTEM_EXTENSIONS (as 
> other libraries are doing) instead of manually fiddling with the 
> _GNU_SOURCE definition.  This increases portability, as most of those 
> definitions are currently hard-coded for __linux__ only.  Tested on 
> x86 GNU/Hurd, and
> x86_64 GNU/Linux is in progress.  OK for trunk once testing completed?

Barry had a question about this change, so let me clarify this:

>     	libcilkrts/
>     	* configure.ac (AC_USE_SYSTEM_EXTENSIONS): Instantiate.
>     	<HAVE_PTHREAD_AFFINITY_NP>: Don't define _GNU_SOURCE.
>     	* configure: Regenerate.
>     	* runtime/os-unix.c [__linux__] (_GNU_SOURCE): Don't define.
>     	* runtime/sysdep-unix.c [__linux__] (_GNU_SOURCE): Likewise.

> --- libcilkrts/configure.ac
> +++ libcilkrts/configure.ac
> @@ -39,6 +39,9 @@ AC_PREREQ([2.64])
>  AC_CANONICAL_SYSTEM
>  target_alias=${target_alias-$host_alias}
>  AC_SUBST(target_alias)
> +
> +AC_USE_SYSTEM_EXTENSIONS

> @@ -188,8 +191,7 @@ AC_LINK_IFELSE(
>  # Check for pthread_{,attr_}[sg]etaffinity_np.
>  AC_LINK_IFELSE(
>   [AC_LANG_PROGRAM(
> -  [#define _GNU_SOURCE
> -   #include <pthread.h>],
> +  [#include <pthread.h>],
>    [cpu_set_t cpuset;
>     pthread_attr_t attr;
>     pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), 
> &cpuset);

> --- libcilkrts/runtime/os-unix.c
> +++ libcilkrts/runtime/os-unix.c
> @@ -36,13 +36,6 @@
>   *  POSSIBILITY OF SUCH DAMAGE.
>   
> **********************************************************************
> ****/
>  
> -#ifdef __linux__
> -    // define _GNU_SOURCE before *any* #include.
> -    // Even <stdint.h> will break later #includes if this macro is not
> -    // already defined when it is #included.
> -#   define _GNU_SOURCE
> -#endif

> --- libcilkrts/runtime/sysdep-unix.c
> +++ libcilkrts/runtime/sysdep-unix.c
> @@ -39,13 +39,6 @@
>   **************************************************************************
>   */
>  
> -#ifdef __linux__
> -    // define _GNU_SOURCE before *any* #include.
> -    // Even <stdint.h> will break later #includes if this macro is not
> -    // already defined when it is #included.
> -#   define _GNU_SOURCE
> -#endif

On Wed, 1 Oct 2014 13:18:51 +0000, "Tannenbaum, Barry M" <barry.m.tannenbaum@intel.com> wrote:
> I've been looking at your 3rd edit to remove the use of _GNU_SOURCE for portability. We didn't define this arbitrarily. We want to call dladdr() to get the shared object associated with an address. The docs state that in order to call this function, we should be defining _GNU_SOURCE.

You're correct that -D_GNU_SOURCE is required for this.  What I proposed is to remove the *manual* _GNU_SOURCE definitions, that are currently conditioned to __linux__, given that I had put AC_USE_SYSTEM_EXTENSIONS into configure.ac, which globally adds -D_GNU_SOURCE as well as other similar defines to the compiler flags, see <https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Posix-Variants.html>.
Of course, this is a bit of a "sledgehammer approach" to the problem, but is what is being done in other libraries that ship with GCC.

Now, I don't know all the contexts in which the libcilkrts code is being built.  I thought all of them -- or, at least those where the _GNU_SOURCE definition does have any effect: GNU systems using glibc -- are using the configure script, but maybe that's not true.  In this case, in these other build systems, if any, also (maybe just unconditionally) add -D_GNU_SOURCE to the compiler flags.  If that's not an option, leave in the manual _GNU_SOURCE definitions in the *.c files, conditioned to __linux__ -- which is ugly ;-) but does fulfil its purpose.

> How should I be determining if this functionality is available?

You can then assume that dladdr is available.


Grüße,
 Thomas

  reply	other threads:[~2014-10-01 14:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BF230D13CA30DD48930C31D4099330003A47B9F3@FMSMSX101.amr.corp.intel.com>
     [not found] ` <525460A9.2040409@redhat.com>
     [not found]   ` <BF230D13CA30DD48930C31D4099330003A48660C@FMSMSX101.amr.corp.intel.com>
2013-11-07 13:36     ` Cilk Library Thomas Schwinge
2013-11-07 17:32       ` Jeff Law
2013-11-07 23:35       ` Iyer, Balaji V
2013-11-08  9:03         ` Thomas Schwinge
2014-09-29 18:13     ` libcilkrts: Use AC_USE_SYSTEM_EXTENSIONS (was: Cilk Library) Thomas Schwinge
2014-10-01 14:02       ` Thomas Schwinge
2014-10-01 14:10         ` Tannenbaum, Barry M [this message]
2014-09-29 18:13     ` libcilkrts: Remove unused function __cilkrts_sysdep_is_worker_thread_id " Thomas Schwinge
2014-09-29 18:26       ` Tannenbaum, Barry M
2014-09-29 21:00       ` libcilkrts: Remove unused function __cilkrts_sysdep_is_worker_thread_id Jeff Law
2014-09-29 21:06         ` Thomas Schwinge
2014-09-29 18:14     ` libcilkrts: GNU toolchain, GNU linker scripts (was: Cilk Library) Thomas Schwinge
2014-09-29 18:14     ` libcilkrts: GNU Hurd port, and some code cleanup/consolidation " Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6B86B7F2A4026246AA81BA1ABF9756905C511EC7@fmsmsx107.amr.corp.intel.com \
    --to=barry.m.tannenbaum@intel.com \
    --cc=balaji.v.iyer@intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=igor.zamyatin@intel.com \
    --cc=thomas@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).