This patch to the Go fronted exports thunks referenced by inline
functions.  Otherwise we get a link time error.  The test case is
https://golang.org/cl/248637.  This fixes
https://golang.org/issue/40252.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline and GCC 10 branch.

Ian
5903b4561331e2a8907937baad8040e58b92aea3
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e443282d0e8..e425f15285e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-fe5d94c5792f7f990004c3dee0ea501835512200
+823c91088bc6ac606362fc34b2880ce0de1624ad
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index d295fd10136..8bbc557c65f 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -1635,16 +1635,15 @@ 
Func_descriptor_expression::do_get_backend(Translate_context* context)
              || no->name().find("equal") != std::string::npos))
        is_exported_runtime = true;
 
-      bool is_referenced_by_inline =
-       no->is_function() && no->func_value()->is_referenced_by_inline();
-
       bool is_hidden = ((no->is_function()
                         && no->func_value()->enclosing() != NULL)
                        || (Gogo::is_hidden_name(no->name())
-                           && !is_exported_runtime
-                           && !is_referenced_by_inline)
+                           && !is_exported_runtime)
                        || Gogo::is_thunk(no));
 
+      if (no->is_function() && no->func_value()->is_referenced_by_inline())
+       is_hidden = false;
+
       bvar = context->backend()->immutable_struct(var_name, asm_name,
                                                   is_hidden, false,
                                                  btype, bloc);
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index 13de74bc870..82d4c1fd54d 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -3370,7 +3370,8 @@ class Create_function_descriptors : public Traverse
   Gogo* gogo_;
 };
 
-// Create a descriptor for every top-level exported function.
+// Create a descriptor for every top-level exported function and every
+// function referenced by an inline function.
 
 int
 Create_function_descriptors::function(Named_object* no)
@@ -3378,8 +3379,9 @@ Create_function_descriptors::function(Named_object* no)
   if (no->is_function()
       && no->func_value()->enclosing() == NULL
       && !no->func_value()->is_method()
-      && !Gogo::is_hidden_name(no->name())
-      && !Gogo::is_thunk(no))
+      && ((!Gogo::is_hidden_name(no->name())
+          && !Gogo::is_thunk(no))
+         || no->func_value()->is_referenced_by_inline()))
     no->func_value()->descriptor(this->gogo_, no);
 
   return TRAVERSE_CONTINUE;

Reply via email to