From patchwork Thu May 8 10:11:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 346966 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3E47B14009C for ; Thu, 8 May 2014 20:11:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=GSH63EQCxJ3r81IJ4 07/ejMr5LONGpWUCmdiQ8GcRhHgZcprG9G5o/I73Ph/fUepRQGBrx77nNtyg1du8 7SGPITsGrpTl3QqOg+G7YeFtVDZc8Zg1aHMoDaVqkr56Qjd3Fxg6y3iziwaVthE9 3CKWX1TESN9MC6nzzqDWhx6BO4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=zpQSxF7P4o33GA18kawJbu4 1T24=; b=tnQsufh1V2pWu8jE6BG9IUHp79jzpvf2WnG3NzYkTAg0sUUJrGuLv/5 mENbGbL5ieIXjxJ1RFnLwcBecXSG9iNuufbRiKwxPzZW/LKoHedoECbN9aJtaywr MFClz4rGauLQ8PGt67fqVyEpyUYKRPd/2QKKhKIoj4Q+bvsHLLGs= Received: (qmail 30049 invoked by alias); 8 May 2014 10:11:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 30040 invoked by uid 89); 8 May 2014 10:11:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 May 2014 10:11:08 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WiLI7-00060j-5T from Bernd_Schmidt@mentor.com ; Thu, 08 May 2014 03:11:03 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 8 May 2014 03:11:02 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Thu, 8 May 2014 11:11:00 +0100 Message-ID: <536B5835.8040002@codesourcery.com> Date: Thu, 8 May 2014 12:11:01 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Ilya Verbin , Jakub Jelinek CC: Thomas Schwinge , GCC Patches , Michael Zolotukhin Subject: Re: [gomp4] Add tables generation References: <532B1C45.9020308@codesourcery.com> <20140320185619.GN1817@tucnak.redhat.com> <532C5729.5050101@codesourcery.com> <20140321152053.GS1817@tucnak.redhat.com> <533E7BC9.8000504@codesourcery.com> <87lhvjhl6e.fsf@kepler.schwinge.homeip.net> <53401FA1.2060407@codesourcery.com> <20140506153204.GA13875@msticlxl57.ims.intel.com> In-Reply-To: <20140506153204.GA13875@msticlxl57.ims.intel.com> On 05/06/2014 05:32 PM, Ilya Verbin wrote: > On 05 Apr 17:22, Bernd Schmidt wrote: >> Things seemed to work over here, but now I'm not certain whether the >> __start_/__stop_ functionality is GNU ld specific? Maybe we should >> just go back to the previous version of this patch which didn't try >> to use this. >> >> Bernd > > This approach does not work with shared libraries. > > The automatically inserted symbols have GLOBAL binding, therefore the > __start_/__stop_ from the executable overwrite the respective symbols in DSO. Ok, I guess we should just go back to what we had previously. Here's what I intend to commit if there are no objections. Bernd Index: gcc/lto-wrapper.c =================================================================== --- gcc/lto-wrapper.c (revision 210170) +++ gcc/lto-wrapper.c (working copy) @@ -66,7 +66,7 @@ static unsigned int nr; static char **input_names; static char **output_names; static char **offload_names; -static const char *ompend; +static const char *ompbegin, *ompend; static char *makefile; const char tool_name[] = "lto-wrapper"; @@ -554,30 +554,40 @@ copy_file (const char *dest, const char } } -/* Find the crtompend.o file in LIBRARY_PATH, make a copy and store - the name of the copy in ompend. */ +/* Find the omp_begin.o and omp_end.o files in LIBRARY_PATH, make copies + and store the names of the copies in ompbegin and ompend. */ static void -find_ompend (void) +find_ompbeginend (void) { char **paths; const char *library_path = getenv ("LIBRARY_PATH"); if (library_path == NULL) return; - int n_paths = parse_env_var (library_path, &paths, "/crtompend.o"); + int n_paths = parse_env_var (library_path, &paths, "/crtompbegin.o"); - for (int i = 0; i < n_paths; i++) + int i; + for (i = 0; i < n_paths; i++) if (access_check (paths[i], R_OK) == 0) { + size_t len = strlen (paths[i]); + char *tmp = xstrdup (paths[i]); + strcpy (paths[i] + len - 7, "end.o"); + if (access_check (paths[i], R_OK) != 0) + fatal ("installation error, can't find crtompend.o"); /* The linker will delete the filenames we give it, so make copies. */ - const char *omptmp = make_temp_file (".o"); - copy_file (omptmp, paths[i]); - ompend = omptmp; + const char *omptmp1 = make_temp_file (".o"); + const char *omptmp2 = make_temp_file (".o"); + copy_file (omptmp1, tmp); + ompbegin = omptmp1; + copy_file (omptmp2, paths[i]); + ompend = omptmp2; + free (tmp); break; } - if (ompend == 0) - fatal ("installation error, can't find crtompend.o"); + if (i == n_paths) + fatal ("installation error, can't find crtompbegin.o"); free_array_of_ptrs ((void**) paths, n_paths); } @@ -1073,7 +1083,7 @@ cont: compile_images_for_openmp_targets (argc, argv); if (offload_names) { - find_ompend (); + find_ompbeginend (); for (i = 0; offload_names[i]; i++) { fputs (offload_names[i], stdout); @@ -1082,6 +1092,11 @@ cont: free_array_of_ptrs ((void **)offload_names, i); } } + if (ompbegin) + { + fputs (ompbegin, stdout); + putc ('\n', stdout); + } for (i = 0; i < nr; ++i) { Index: libgcc/Makefile.in =================================================================== --- libgcc/Makefile.in (revision 210170) +++ libgcc/Makefile.in (working copy) @@ -975,6 +975,9 @@ crtbegin$(objext): $(srcdir)/crtstuff.c crtend$(objext): $(srcdir)/crtstuff.c $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END +crtompbegin$(objext): $(srcdir)/ompstuff.c + $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN + crtompend$(objext): $(srcdir)/ompstuff.c $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END Index: libgcc/configure =================================================================== --- libgcc/configure (revision 210170) +++ libgcc/configure (working copy) @@ -4397,7 +4397,7 @@ fi if test x$offload_targets != x; then - extra_parts="${extra_parts} crtompend.o" + extra_parts="${extra_parts} crtompbegin.o crtompend.o" fi # Check if Solaris/x86 linker supports ZERO terminator unwind entries. Index: libgcc/configure.ac =================================================================== --- libgcc/configure.ac (revision 210170) +++ libgcc/configure.ac (working copy) @@ -336,7 +336,7 @@ AC_ARG_ENABLE(offload-targets, ], [enable_accelerator=no]) AC_SUBST(enable_accelerator) if test x$offload_targets != x; then - extra_parts="${extra_parts} crtompend.o" + extra_parts="${extra_parts} crtompbegin.o crtompend.o" fi # Check if Solaris/x86 linker supports ZERO terminator unwind entries. Index: libgcc/ompstuff.c =================================================================== --- libgcc/ompstuff.c (revision 210170) +++ libgcc/ompstuff.c (working copy) @@ -39,14 +39,35 @@ see the files COPYING3 and COPYING.RUNTI #include "tm.h" #include "libgcc_tm.h" +#ifdef CRT_BEGIN + #if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) -extern void __start___gnu_offload_funcs; -extern void __stop___gnu_offload_funcs; -extern void __start___gnu_offload_vars; -extern void __stop___gnu_offload_vars; +void *_omp_func_table[0] + __attribute__ ((__used__, visibility ("hidden"), + section (".offload_func_table_section"))) = { }; +void *_omp_var_table[0] + __attribute__ ((__used__, visibility ("hidden"), + section (".offload_var_table_section"))) = { }; +#endif + +#elif defined CRT_END + +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) +void *_omp_funcs_end[0] + __attribute__ ((__used__, visibility ("hidden"), + section (".offload_func_table_section"))) = { }; +void *_omp_vars_end[0] + __attribute__ ((__used__, visibility ("hidden"), + section (".offload_var_table_section"))) = { }; +extern void *_omp_func_table[]; +extern void *_omp_var_table[]; void *__OPENMP_TARGET__[] __attribute__ ((__visibility__ ("hidden"))) = { - &__start___gnu_offload_funcs, &__stop___gnu_offload_funcs, - &__start___gnu_offload_vars, &__stop___gnu_offload_vars + &_omp_func_table, &_omp_funcs_end, + &_omp_var_table, &_omp_vars_end }; #endif + +#else /* ! CRT_BEGIN && ! CRT_END */ +#error "One of CRT_BEGIN or CRT_END must be defined." +#endif