modula-2: Module registration constructors need to be visible [PR108259].

Message ID 20230102113922.5458-1-iain@sandoe.co.uk
State Committed
Commit 751c2d9a46f786381a90d5c8c49947fa0d9b7ee5
Headers
Series modula-2: Module registration constructors need to be visible [PR108259]. |

Commit Message

Iain Sandoe Jan. 2, 2023, 11:39 a.m. UTC
  Tested on x86_64-linux-gnu, x86_64,aarch64-darwin21.
There remain issues with shared libraries, but the link fails are fixed
by this.

OK for master?
Thanks
Iain

--- 8< ---

In the current design the main executable links explicitly to the module
registration construtors that it uses.  This means that they must be
visible in shared libraries.

	PR modula2/108259

gcc/m2/ChangeLog:

	* gm2-gcc/m2decl.cc (m2decl_DeclareModuleCtor): Make module
	registration constructors visible.
---
 gcc/m2/gm2-gcc/m2decl.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Gaius Mulley Jan. 4, 2023, 12:07 p.m. UTC | #1
Iain Sandoe <iains.gcc@gmail.com> writes:

> Tested on x86_64-linux-gnu, x86_64,aarch64-darwin21.
> There remain issues with shared libraries, but the link fails are fixed
> by this.
>
> OK for master?
> Thanks
> Iain
>
> --- 8< ---
>
> In the current design the main executable links explicitly to the module
> registration construtors that it uses.  This means that they must be
> visible in shared libraries.
>
> 	PR modula2/108259
>
> gcc/m2/ChangeLog:
>
> 	* gm2-gcc/m2decl.cc (m2decl_DeclareModuleCtor): Make module
> 	registration constructors visible.
> ---
>  gcc/m2/gm2-gcc/m2decl.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/m2/gm2-gcc/m2decl.cc b/gcc/m2/gm2-gcc/m2decl.cc
> index 62bfefd2530..d849f8aefc4 100644
> --- a/gcc/m2/gm2-gcc/m2decl.cc
> +++ b/gcc/m2/gm2-gcc/m2decl.cc
> @@ -276,7 +276,7 @@ m2decl_DeclareModuleCtor (tree decl)
>    /* Declare module_ctor ().  */
>    TREE_PUBLIC (decl) = 1;
>    DECL_ARTIFICIAL (decl) = 1;
> -  DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
> +  DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
>    DECL_VISIBILITY_SPECIFIED (decl) = 1;
>    DECL_STATIC_CONSTRUCTOR (decl) = 1;
>    return decl;

LGTM thanks,

Gaius
  

Patch

diff --git a/gcc/m2/gm2-gcc/m2decl.cc b/gcc/m2/gm2-gcc/m2decl.cc
index 62bfefd2530..d849f8aefc4 100644
--- a/gcc/m2/gm2-gcc/m2decl.cc
+++ b/gcc/m2/gm2-gcc/m2decl.cc
@@ -276,7 +276,7 @@  m2decl_DeclareModuleCtor (tree decl)
   /* Declare module_ctor ().  */
   TREE_PUBLIC (decl) = 1;
   DECL_ARTIFICIAL (decl) = 1;
-  DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
+  DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
   DECL_VISIBILITY_SPECIFIED (decl) = 1;
   DECL_STATIC_CONSTRUCTOR (decl) = 1;
   return decl;