Enable math functions linking with static library for LTO
[gcc.git] / gcc / symtab.c
index 63e2820eb93b51fe7e11a0e5b78fa02ce455ef5c..ee9723c34534ff64540ced7c38e30b45c329f47c 100644 (file)
@@ -2375,10 +2375,18 @@ symtab_node::output_to_lto_symbol_table_p (void)
      first place.  */
   if (VAR_P (decl) && DECL_HARD_REGISTER (decl))
     return false;
-  /* FIXME: Builtins corresponding to real functions probably should have
-     symbol table entries.  */
-  if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
-    return false;
+  if (TREE_CODE (decl) == FUNCTION_DECL && !definition
+      && fndecl_built_in_p (decl))
+    {
+      /* Builtins like those for most math functions have actual implementations
+        in libraries so make sure to output references into the symbol table to
+        make those libraries referenced.  Note this is incomplete handling for
+        now and only covers math functions.  */
+      if (builtin_with_linkage_p (decl))
+       return true;
+      else
+       return false;
+    }
 
   /* We have real symbol that should be in symbol table.  However try to trim
      down the refernces to libraries bit more because linker will otherwise