I have used the darwin files as templates and made the necessary changes. It reduces test failures from over 15000 (all run tests) to 27 in 3 files (patch for PR 48244 applied as well) on NetBSD 7.0 amd64.
--- /dev/null 2014-12-15 07:13:57.000000000 +0000 +++ gcc/config/netbsd-protos.h @@ -0,0 +1,29 @@ +/* Prototypes. + Copyright (C) 2001-2014 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _NETBSD_PROTOS_H_ +#define _NETBSD_PROTOS_H_ + +double __c99_cabs (double complex); +float __c99_cabsf (float complex); +long double __c99_cabsl (long double complex); + +void netbsd_patch_builtins (void); + +#endif /* _NETBSD_PROTOS_H_ */ --- /dev/null 2014-12-17 06:10:54.000000000 +0000 +++ gcc/config/netbsd.c @@ -0,0 +1,106 @@ +/* Functions for generic NetBSD as target machine for GNU C compiler. + Copyright (C) 1989-2014 Free Software Foundation, Inc. + Contributed by Apple Computer Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "rtl.h" +#include "regs.h" +#include "hard-reg-set.h" +#include "insn-config.h" +#include "conditions.h" +#include "insn-flags.h" +#include "output.h" +#include "insn-attr.h" +#include "flags.h" +#include "tree.h" +#include "stringpool.h" +#include "varasm.h" +#include "stor-layout.h" +#include "expr.h" +#include "reload.h" +#include "hashtab.h" +#include "hash-set.h" +#include "vec.h" +#include "machmode.h" +#include "input.h" +#include "function.h" +#include "ggc.h" +#include "langhooks.h" +#include "target.h" +#include "tm_p.h" +#include "diagnostic-core.h" +#include "toplev.h" +#include "dominance.h" +#include "cfg.h" +#include "cfgrtl.h" +#include "cfganal.h" +#include "lcm.h" +#include "cfgbuild.h" +#include "cfgcleanup.h" +#include "predict.h" +#include "basic-block.h" +#include "df.h" +#include "debug.h" +#include "obstack.h" +#include "hash-table.h" +#include "tree-ssa-alias.h" +#include "internal-fn.h" +#include "gimple-fold.h" +#include "tree-eh.h" +#include "gimple-expr.h" +#include "is-a.h" +#include "gimple.h" +#include "gimplify.h" +#include "hash-map.h" +#include "plugin-api.h" +#include "ipa-ref.h" +#include "cgraph.h" +#include "lto-streamer.h" +#include "lto-section-names.h" + +static void +netbsd_patch_builtin (enum built_in_function fncode) +{ + tree fn = builtin_decl_explicit (fncode); + tree sym; + char *newname; + + if (!fn) + return; + + sym = DECL_ASSEMBLER_NAME (fn); + newname = ACONCAT (("__c99_", IDENTIFIER_POINTER (sym), NULL)); + + set_user_assembler_name (fn, newname); + + fn = builtin_decl_implicit (fncode); + if (fn) + set_user_assembler_name (fn, newname); +} + +void +netbsd_patch_builtins (void) +{ + netbsd_patch_builtin (BUILT_IN_CABSF); + netbsd_patch_builtin (BUILT_IN_CABS); + netbsd_patch_builtin (BUILT_IN_CABSL); +} --- gcc/config/netbsd.h.orig 2014-01-02 22:23:26.000000000 +0000 +++ gcc/config/netbsd.h @@ -17,6 +17,9 @@ You should have received a copy of the G along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ + +#include "netbsd-protos.h" + /* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets. */ #define NETBSD_OS_CPP_BUILTINS_COMMON() \ do \ @@ -175,3 +178,9 @@ along with GCC; see the file COPYING3. #undef WINT_TYPE #define WINT_TYPE "int" + +#undef SUBTARGET_INIT_BUILTINS +#define SUBTARGET_INIT_BUILTINS \ +do { \ + netbsd_patch_builtins (); \ +} while(0) --- /dev/null 2014-12-16 20:23:05.000000000 +0000 +++ gcc/config/t-netbsd @@ -0,0 +1,23 @@ +# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + + +netbsd.o: $(srcdir)/config/netbsd.c + $(COMPILE) $< + $(POSTCOMPILE) +