bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc
@ 2021-05-25 15:54 Ozkan Sezer
  2021-05-25 23:54 ` Bruno Haible
  0 siblings, 1 reply; 5+ messages in thread
From: Ozkan Sezer @ 2021-05-25 15:54 UTC (permalink / raw)
  To: bug-gnulib

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

The attached patch makes gl_VISIBILITY to reject unsupported configurations
with newer gcc: In its current form, mingw gcc-4.5.4 rejects the attributes
but gcc-7.5 does not, apparently because the attributes are applied to func
prototypes without their definitions.  Attaching a hidden visibility attrib
to dummyfunc() makes gcc-7.5 to reject it properly.

--
O.S.

[-- Attachment #2: 0001-visibility.m4-make-gl_VISIBILITY-to-reject-unsupport.patch --]
[-- Type: text/x-patch, Size: 1248 bytes --]

From 1c7e9ca1f5ad6f2b7dcd65f0bdfefec16ff6ad06 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <sezeroz@gmail.com>
Date: Tue, 25 May 2021 18:47:14 +0300
Subject: [PATCH] m4/visibility.m4 (gl_VISIBILITY): properly reject unsupported configurations with newer gcc

---
 m4/visibility.m4 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/m4/visibility.m4 b/m4/visibility.m4
index 8f27a12..91970a9 100644
--- a/m4/visibility.m4
+++ b/m4/visibility.m4
@@ -1,4 +1,4 @@
-# visibility.m4 serial 7
+# visibility.m4 serial 8
 dnl Copyright (C) 2005, 2008, 2010-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -58,7 +58,7 @@ AC_DEFUN([gl_VISIBILITY],
               extern __attribute__((__visibility__("default"))) int exportedvar;
               extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
               extern __attribute__((__visibility__("default"))) int exportedfunc (void);
-              void dummyfunc (void);
+              extern __attribute__((__visibility__("hidden"))) void dummyfunc (void);
               void dummyfunc (void) {}
             ]],
             [[]])],
-- 
1.7.1


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

* Re: [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc
  2021-05-25 15:54 [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc Ozkan Sezer
@ 2021-05-25 23:54 ` Bruno Haible
  2021-05-26  0:34   ` Ozkan Sezer
  0 siblings, 1 reply; 5+ messages in thread
From: Bruno Haible @ 2021-05-25 23:54 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Ozkan Sezer

Hi,

Ozkan Sezer wrote:
> The attached patch makes gl_VISIBILITY to reject unsupported configurations
> with newer gcc: In its current form, mingw gcc-4.5.4 rejects the attributes
> but gcc-7.5 does not, apparently because the attributes are applied to func
> prototypes without their definitions.  Attaching a hidden visibility attrib
> to dummyfunc() makes gcc-7.5 to reject it properly.

I don't fully understand why we should apply the patch.

With gcc 7.5 on mingw and the visibility.m4 that is in gnulib now:
What is the result of the
  checking for simple visibility declarations...
test? What are the effects: warnings? compilation errors? link errors? too
many exported symbols? too few exported symbols?

Maybe you also have a test case, that you could show?

Bruno



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

* Re: [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc
  2021-05-25 23:54 ` Bruno Haible
@ 2021-05-26  0:34   ` Ozkan Sezer
  2021-06-05 15:10     ` Bruno Haible
  0 siblings, 1 reply; 5+ messages in thread
From: Ozkan Sezer @ 2021-05-26  0:34 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

>> The attached patch makes gl_VISIBILITY to reject unsupported configurations
>> with newer gcc: In its current form, mingw gcc-4.5.4 rejects the attributes
>> but gcc-7.5 does not, apparently because the attributes are applied to func
>> prototypes without their definitions.  Attaching a hidden visibility attrib
>> to dummyfunc() makes gcc-7.5 to reject it properly.
>
> I don't fully understand why we should apply the patch.
>
> With gcc 7.5 on mingw and the visibility.m4 that is in gnulib now:
> What is the result of the
>   checking for simple visibility declarations...
> test? What are the effects: warnings? compilation errors? link errors? too
> many exported symbols? too few exported symbols?

No warnings from the testcase in m4. In real-life, it results in warnings,
see e.g.: https://github.com/libsndfile/libsamplerate/issues/154

> Maybe you also have a test case, that you could show?

The above bug report should cover it I think. If not, tell me.

> Bruno
>

--
O.S.


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

* Re: [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc
  2021-05-26  0:34   ` Ozkan Sezer
@ 2021-06-05 15:10     ` Bruno Haible
  2021-06-05 16:21       ` Ozkan Sezer
  0 siblings, 1 reply; 5+ messages in thread
From: Bruno Haible @ 2021-06-05 15:10 UTC (permalink / raw)
  To: Ozkan Sezer; +Cc: bug-gnulib

Ozkan Sezer wrote:
> >> The attached patch makes gl_VISIBILITY to reject unsupported configurations
> >> with newer gcc: In its current form, mingw gcc-4.5.4 rejects the attributes
> >> but gcc-7.5 does not, apparently because the attributes are applied to func
> >> prototypes without their definitions.  Attaching a hidden visibility attrib
> >> to dummyfunc() makes gcc-7.5 to reject it properly.
> >
> > I don't fully understand why we should apply the patch.
> >
> > With gcc 7.5 on mingw and the visibility.m4 that is in gnulib now:
> > What is the result of the
> >   checking for simple visibility declarations...
> > test? What are the effects: warnings? compilation errors? link errors? too
> > many exported symbols? too few exported symbols?
> 
> No warnings from the testcase in m4. In real-life, it results in warnings,
> see e.g.: https://github.com/libsndfile/libsamplerate/issues/154

OK, I understand better now.

In the GCC source code I see that the
  "visibility attribute not supported in this configuration; ignored"
warning is emitted when a definition is emitted. Therefore I think the
safest patch is to add a definition for each declaration in the test code.


2021-06-05  Bruno Haible  <bruno@clisp.org>

	lib-symbol-visibility: Make configure check work for newer GCC.
	Reported by Ozkan Sezer <sezeroz@gmail.com> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00117.html>.
	* m4/visibility.m4 (gl_VISIBILITY): Add a function definition for each
	declaration in the test program.

diff --git a/m4/visibility.m4 b/m4/visibility.m4
index 8f27a12..d161bd7 100644
--- a/m4/visibility.m4
+++ b/m4/visibility.m4
@@ -1,4 +1,4 @@
-# visibility.m4 serial 7
+# visibility.m4 serial 8
 dnl Copyright (C) 2005, 2008, 2010-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -59,6 +59,10 @@ AC_DEFUN([gl_VISIBILITY],
               extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
               extern __attribute__((__visibility__("default"))) int exportedfunc (void);
               void dummyfunc (void);
+              int hiddenvar;
+              int exportedvar;
+              int hiddenfunc (void) { return 51; }
+              int exportedfunc (void) { return 1225736919; }
               void dummyfunc (void) {}
             ]],
             [[]])],



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

* Re: [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc
  2021-06-05 15:10     ` Bruno Haible
@ 2021-06-05 16:21       ` Ozkan Sezer
  0 siblings, 0 replies; 5+ messages in thread
From: Ozkan Sezer @ 2021-06-05 16:21 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

On 6/5/21, Bruno Haible <bruno@clisp.org> wrote:
> Ozkan Sezer wrote:
>> >> The attached patch makes gl_VISIBILITY to reject unsupported
>> >> configurations
>> >> with newer gcc: In its current form, mingw gcc-4.5.4 rejects the
>> >> attributes
>> >> but gcc-7.5 does not, apparently because the attributes are applied to
>> >> func
>> >> prototypes without their definitions.  Attaching a hidden visibility
>> >> attrib
>> >> to dummyfunc() makes gcc-7.5 to reject it properly.
>> >
>> > I don't fully understand why we should apply the patch.
>> >
>> > With gcc 7.5 on mingw and the visibility.m4 that is in gnulib now:
>> > What is the result of the
>> >   checking for simple visibility declarations...
>> > test? What are the effects: warnings? compilation errors? link errors?
>> > too
>> > many exported symbols? too few exported symbols?
>>
>> No warnings from the testcase in m4. In real-life, it results in
>> warnings,
>> see e.g.: https://github.com/libsndfile/libsamplerate/issues/154
>
> OK, I understand better now.
>
> In the GCC source code I see that the
>   "visibility attribute not supported in this configuration; ignored"
> warning is emitted when a definition is emitted. Therefore I think the
> safest patch is to add a definition for each declaration in the test code.
>
>
> 2021-06-05  Bruno Haible  <bruno@clisp.org>
>
> 	lib-symbol-visibility: Make configure check work for newer GCC.
> 	Reported by Ozkan Sezer <sezeroz@gmail.com> in
> 	<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00117.html>.
> 	* m4/visibility.m4 (gl_VISIBILITY): Add a function definition for each
> 	declaration in the test program.
>
> diff --git a/m4/visibility.m4 b/m4/visibility.m4
> index 8f27a12..d161bd7 100644
> --- a/m4/visibility.m4
> +++ b/m4/visibility.m4
> @@ -1,4 +1,4 @@
> -# visibility.m4 serial 7
> +# visibility.m4 serial 8
>  dnl Copyright (C) 2005, 2008, 2010-2021 Free Software Foundation, Inc.
>  dnl This file is free software; the Free Software Foundation
>  dnl gives unlimited permission to copy and/or distribute it,
> @@ -59,6 +59,10 @@ AC_DEFUN([gl_VISIBILITY],
>                extern __attribute__((__visibility__("hidden"))) int
> hiddenfunc (void);
>                extern __attribute__((__visibility__("default"))) int
> exportedfunc (void);
>                void dummyfunc (void);
> +              int hiddenvar;
> +              int exportedvar;
> +              int hiddenfunc (void) { return 51; }
> +              int exportedfunc (void) { return 1225736919; }
>                void dummyfunc (void) {}
>              ]],
>              [[]])],
>
>

Works for me:

configure:13230: checking for simple visibility declarations
configure:13261: x86_64-w64-mingw32-gcc -c -g -O2 -Wall
-fvisibility=hidden -Werror  conftest.c >&5
conftest.c: In function 'hiddenfunc':
conftest.c:37:15: error: visibility attribute not supported in this
configuration; ignored [-Werror=attributes]
               int hiddenfunc (void) { return 51; }
               ^~~
conftest.c: At top level:
conftest.c:47:1: error: visibility attribute not supported in this
configuration; ignored [-Werror=attributes]
 }
 ^
cc1: all warnings being treated as errors
configure:13261: $? = 1


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

end of thread, other threads:[~2021-06-05 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 15:54 [PATCH] make gl_VISIBILITY to reject unsupported configurations with newer gcc Ozkan Sezer
2021-05-25 23:54 ` Bruno Haible
2021-05-26  0:34   ` Ozkan Sezer
2021-06-05 15:10     ` Bruno Haible
2021-06-05 16:21       ` Ozkan Sezer

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