public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [rfc] towards a defined abi for libgfortran
       [not found] ` <DA243E46-47ED-11D9-840F-000A95D692F4@physics.uc.edu>
@ 2004-12-11  3:55   ` Andrew Pinski
  2004-12-11  6:57     ` Andrew Pinski
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2004-12-11  3:55 UTC (permalink / raw)
  To: GCC ML, Andrew Pinski; +Cc: fortran, Richard Henderson


On Dec 6, 2004, at 8:18 PM, Andrew Pinski wrote:

>
> On Dec 6, 2004, at 7:41 PM, Richard Henderson wrote:
>
>> A prerequisite for being able to point to an ABI is symbol access 
>> control.
>> Namely, you don't want to expose any symbols that you don't mean to 
>> expose.
>>
>> The following patch replaces the prefix macro with a set of fine-grain
>> macros that do allow us to control which symbols are seen by user 
>> apps.
>>
>> On elf systems, it will use __attribute__((visibility("hidden"))) to
>> prevent specific symbols from escaping the library.  It will also use
>> __attribute__((alias(...))) to reduce the number of PLT entries needed
>> when calling routines that we do intend to export.
>> Comments?
>
> I will test this on darwin which has visibility("hidden") but not 
> alias.

This failed but due to a compiler bug.
The following code is not able to compile on darwin because
the target says options is defined when it is not because it is
a common symbol.

int options  __attribute__((__visibility__("hidden")));

void f(void)
{
   options = 0;
}

I will look into fixing this and test the patch again.  This is a
regression from when Mark rewrote part of the darwin backend.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rfc] towards a defined abi for libgfortran
  2004-12-11  3:55   ` [rfc] towards a defined abi for libgfortran Andrew Pinski
@ 2004-12-11  6:57     ` Andrew Pinski
  2004-12-14  0:58       ` Mike Stump
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2004-12-11  6:57 UTC (permalink / raw)
  To: GCC Patches, Andrew Pinski; +Cc: fortran, GCC ML, Richard Henderson

[-- Attachment #1: Type: text/plain, Size: 904 bytes --]


On Dec 10, 2004, at 10:55 PM, Andrew Pinski wrote:
>
> This failed but due to a compiler bug.
> The following code is not able to compile on darwin because
> the target says options is defined when it is not because it is
> a common symbol.
>
> int options  __attribute__((__visibility__("hidden")));
>
> void f(void)
> {
>   options = 0;
> }
>
> I will look into fixing this and test the patch again.  This is a
> regression from when Mark rewrote part of the darwin backend.

And here is a patch which fixes this regression.  I also took
the time to add some comments to the function which was causing
the problem.

Also the patch from RTH does not cause any regression in the
fortran testsuite.

OK? Bootstrapped and tested on ppc-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
	* config/darwin.c (machopic_symbol_defined_p): Return false
	if the binds local and is a common symbol.


[-- Attachment #2: temp.diff.txt --]
[-- Type: text/plain, Size: 1466 bytes --]

Index: darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.97
diff -u -p -r1.97 darwin.c
--- darwin.c	19 Nov 2004 18:01:53 -0000	1.97
+++ darwin.c	11 Dec 2004 05:05:53 -0000
@@ -90,16 +90,30 @@ name_needs_quotes (const char *name)
   return 0;
 }
 
-/*
- * flag_pic = 1 ... generate only indirections
- * flag_pic = 2 ... generate indirections and pure code
- */
-
+/* Return true if SYM_REF can be used without an indirection.  */
 static int
 machopic_symbol_defined_p (rtx sym_ref)
 {
-  return (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
-    || (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref));
+  if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
+    return true;
+
+  /* If a symbol references local and is not an extern to this
+     file, then the symbol might be able to declared as defined.  */
+  if (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref))
+    {
+      /* If the symbol references a variable and the variable is a
+	 common symbol, then this symbol is not defined.  */
+      if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_VARIABLE)
+	{
+	  tree decl = SYMBOL_REF_DECL (sym_ref);
+	  if (!decl)
+	    return true;
+	  if (DECL_COMMON (decl))
+	    return false;
+	}
+      return true;
+    }
+  return false;
 }
 
 /* This module assumes that (const (symbol_ref "foo")) is a legal pic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rfc] towards a defined abi for libgfortran
  2004-12-11  6:57     ` Andrew Pinski
@ 2004-12-14  0:58       ` Mike Stump
  2004-12-14  1:14         ` Mike Stump
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Stump @ 2004-12-14  0:58 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches, fortran, GCC ML, Richard Henderson

On Dec 10, 2004, at 10:57 PM, Andrew Pinski wrote:
> OK?
I think this is the wrong patch. In default_binds_local_p_1, we have:

bool
default_binds_local_p_1 (tree exp, int shlib)
{
  bool local_p;

  /* A non-decl is an entry in the constant pool. */
  if (!DECL_P (exp))
  local_p = true;
  /* Static variables are always local. */
  else if (! TREE_PUBLIC (exp))
  local_p = true;
  /* A variable is local if the user explicitly tells us so. */
  else if (DECL_VISIBILITY_SPECIFIED (exp) && DECL_VISIBILITY (exp) != 
VISIBILITY_DEFAULT)
  local_p = true;

In the test case given, you specify the visibility, and it isn't the 
default, so this code says that it is local. But, a hidden common isn't 
local, right? So, that would mean the code above is wrong?

Adding a ! DECL_COMMON (exp) && might be one way to avoid it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rfc] towards a defined abi for libgfortran
  2004-12-14  0:58       ` Mike Stump
@ 2004-12-14  1:14         ` Mike Stump
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Stump @ 2004-12-14  1:14 UTC (permalink / raw)
  To: Mike Stump; +Cc: Andrew Pinski, GCC Patches, fortran, GCC ML, Richard Henderson

On Dec 13, 2004, at 4:57 PM, Mike Stump wrote:
> In the test case given, you specify the visibility, and it isn't the 
> default, so this code says that it is local. But, a hidden common 
> isn't local, right?
Gosh, we've been through this before... I did expect to commit the last 
lesson to a few neurons... Oh well...

Nope, I was wrong, local is fine to set here... The darwin port is 
wrong... Andrew's patch looks correct.

Sorry about that.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-14  1:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20041207004150.GA5856@twiddle.net>
     [not found] ` <DA243E46-47ED-11D9-840F-000A95D692F4@physics.uc.edu>
2004-12-11  3:55   ` [rfc] towards a defined abi for libgfortran Andrew Pinski
2004-12-11  6:57     ` Andrew Pinski
2004-12-14  0:58       ` Mike Stump
2004-12-14  1:14         ` Mike Stump

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).