The following test-case fails in LIPO mode during profile-use build: main.cc ------------ __attribute__((target("sse4.2"))) unsigned int problem_aux (unsigned int A, unsigned int B);
int main (int argc, char *argv[]) { return problem_aux (0, 0); } aux.cc --------- __attribute__((target("sse4.2"))) unsigned int problem_aux (unsigned int A, unsigned int B) { return __builtin_ia32_crc32qi (A, B); } $ g++ -O2 -fprofile-generate main.cc aux.cc $ ./a.out $ g++ -O2 -fprofile-use main.cc error: '__builtin_ia32_crc32qi' was not declared in this scope This happens when parsing the auxiliary module. __builtin_ia32_crc32qi is a target specific builtin that gets created after the target attribute is seen in the declaration of problem_aux in the primary module. This is too late for adding theisbuiltin to the list of knowns, the buitlins get saved when cp_save_built_in_decl_pre_parsing in cp/cp-objcp-common.c is called much earlier. Hence, this builtin which is created during primary module parsing is not available when parsing the auxiliary module. A simple fix is to expose all target builtins unconditionally in LIPO mode. Patch: Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 201046) +++ config/i386/i386.c (working copy) @@ -26957,7 +26957,8 @@ def_builtin (HOST_WIDE_INT mask, const char *name, ix86_builtins_isa[(int) code].isa = mask; mask &= ~OPTION_MASK_ISA_64BIT; - if (mask == 0 + if (flag_dyn_ipa + || mask == 0 || (mask & ix86_isa_flags) != 0 || (lang_hooks.builtin_function == lang_hooks.builtin_function_ext_scope)) Is this ok? Thanks Sri