> On Fri, Jan 03, 2025 at 05:18:55PM +0000, xxx wrote:
>> From: yxj-github-437 <2457369...@qq.com>
>>
>> This patch attempts to fix an error when build module std. The reason for the
>> error is __builrin_va_list (aka struct __va_list) is an internal linkage. so
>> attempt to handle this builtin type by identifying whether 
>> DECL_SOURCE_LOCATION (entity)
>> is BUILTINS_LOCATION.
>>
>
> Hi, thanks for the patch!  I suspect this may not be sufficient to
> completely avoid issues with the __gnuc_va_list type; in particular, if
> it's internal linkage that may prevent it from being referred to in
> other ways by inline functions in named modules (due to P1815).
>
> Maybe a better approach would be to instead mark this builtin type as
> TREE_PUBLIC (presumably in aarch64_build_builtin_va_list)?

Thanks, I change my patch to mark TREE_PUBLIC.

-- >8 --

This patch attempts to fix an error when build module std. The reason for the
error is __builtin_va_list (aka struct __va_list) has internal linkage.
so mark this builtin type as TREE_PUBLIC to make struct __va_list has
external linkage.

/x/gcc-15.0.0/usr/bin/aarch64-linux-android-g++ -fmodules -std=c++23 -fPIC -O2
-fsearch-include-path bits/std.cc -c
/x/gcc-15.0.0/usr/lib/gcc/aarch64-linux-android/15.0.0/include/c++/bits/std.cc:3642:14:
error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external 
linkage
 3642 |   using std::va_list;
      |              ^~~~~~~
<built-in>: note: ‘struct __va_list’ declared here with internal linkage

gcc
        * config/aarch64/aarch64.cc (aarch64_build_builtin_va_list): mark 
__builtin_va_list
        as TREE_PUBLIC
        * config/arm/arm.cc (arm_build_builtin_va_list): mark __builtin_va_list
        as TREE_PUBLIC
        * testsuite/g++.dg/modules/builtin-8.C: New test
---
 gcc/config/aarch64/aarch64.cc            | 1 +
 gcc/config/arm/arm.cc                    | 1 +
 gcc/testsuite/g++.dg/modules/builtin-8.C | 9 +++++++++
 3 files changed, 11 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/modules/builtin-8.C

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index ad31e9d255c..e022526e573 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -21566,6 +21566,7 @@ aarch64_build_builtin_va_list (void)
                             get_identifier ("__va_list"),
                             va_list_type);
   DECL_ARTIFICIAL (va_list_name) = 1;
+  TREE_PUBLIC (va_list_name) = 1;
   TYPE_NAME (va_list_type) = va_list_name;
   TYPE_STUB_DECL (va_list_type) = va_list_name;
 
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 1e0791dc8c2..86838ebde5f 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -2906,6 +2906,7 @@ arm_build_builtin_va_list (void)
                             get_identifier ("__va_list"),
                             va_list_type);
   DECL_ARTIFICIAL (va_list_name) = 1;
+  TREE_PUBLIC (va_list_name) = 1;
   TYPE_NAME (va_list_type) = va_list_name;
   TYPE_STUB_DECL (va_list_type) = va_list_name;
   /* Create the __ap field.  */
diff --git a/gcc/testsuite/g++.dg/modules/builtin-8.C 
b/gcc/testsuite/g++.dg/modules/builtin-8.C
new file mode 100644
index 00000000000..ff91104e4a9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/builtin-8.C
@@ -0,0 +1,9 @@
+// { dg-additional-options -fmodules-ts }
+module;
+#include <stdarg.h>
+export module builtins;
+// { dg-module-cmi builtins }
+
+export {
+  using ::va_list;
+}
-- 
2.43.0

Reply via email to