aboutsummaryrefslogtreecommitdiff
path: root/gcc/symtab.c
diff options
context:
space:
mode:
authorXiong Hu Luo <luoxhu@linux.ibm.com>2019-08-14 02:18:33 +0000
committerXiong Hu Luo <luoxhu@gcc.gnu.org>2019-08-14 02:18:33 +0000
commit5747e0c0e1bce0df39ab7ac342162ecdc6e1343d (patch)
treea0ffc5e9ca2f76f3a97f9789f8956e8d11d02f53 /gcc/symtab.c
parent37987c39eb22e5666745fd5edcfc518d1e59ed72 (diff)
downloadgcc-5747e0c0e1bce0df39ab7ac342162ecdc6e1343d.zip
gcc-5747e0c0e1bce0df39ab7ac342162ecdc6e1343d.tar.gz
gcc-5747e0c0e1bce0df39ab7ac342162ecdc6e1343d.tar.bz2
Enable math functions linking with static library for LTO
In LTO mode, if static library and dynamic library contains same function and both libraries are passed as arguments, linker will link the function in dynamic library no matter the sequence. This patch will output LTO symbol node as UNDEF if BUILT_IN_NORMAL function FNDECL is a math function, then the function in static library will be linked first if its sequence is ahead of the dynamic library. gcc/ChangeLog 2019-08-14 Xiong Hu Luo <luoxhu@linux.ibm.com> PR lto/91287 * builtins.c (builtin_with_linkage_p): New function. * builtins.h (builtin_with_linkage_p): New function. * symtab.c (write_symbol): Remove redundant assert. * lto-streamer-out.c (symtab_node::output_to_lto_symbol_table_p): Remove FIXME and use builtin_with_linkage_p. From-SVN: r274411
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r--gcc/symtab.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 63e2820..ee9723c 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -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