saved_chain = TREE_CHAIN (t);
TREE_CHAIN (t) = NULL_TREE;
- stream_write_tree (ob, t, ref_p);
+ /* We avoid outputting external vars or functions by reference
+ to the global decls section as we do not want to have them
+ enter decl merging. This is, of course, only for the call
+ for streaming BLOCK_VARS, but other callers are safe. */
+ stream_write_tree (ob, t,
+ ref_p && !(VAR_OR_FUNCTION_DECL_P (t)
+ && DECL_EXTERNAL (t)));
TREE_CHAIN (t) = saved_chain;
t = TREE_CHAIN (t);