Index: erts/emulator/sys/unix/erl_unix_sys.h
--- erts/emulator/sys/unix/erl_unix_sys.h.orig	2017-06-20 20:56:09.000000000 +0200
+++ erts/emulator/sys/unix/erl_unix_sys.h	2017-06-21 15:11:51.354946000 +0200
@@ -331,7 +331,7 @@
 #ifdef USE_ISINF_ISNAN		/* simulate finite() */
 #  define isfinite(f) (!isinf(f) && !isnan(f))
 #  define HAVE_ISFINITE
-#elif (defined(__GNUC__) && !defined(__llvm__)) && defined(HAVE_FINITE)
+#elif (defined(__GNUC__) && !defined(__llvm__)) && defined(HAVE_FINITE) && !defined(__FreeBSD__)
 /* We use finite in gcc as it emits assembler instead of
    the function call that isfinite emits. The assembler is
    significantly faster. */
Index: lib/erl_interface/src/connect/ei_resolve.c
--- lib/erl_interface/src/connect/ei_resolve.c.orig	2017-06-20 20:56:09.000000000 +0200
+++ lib/erl_interface/src/connect/ei_resolve.c	2017-06-21 15:11:51.355149000 +0200
@@ -55,6 +55,10 @@
 #include "ei_resolve.h"
 #include "ei_locking.h"
 
+#if defined(HAVE_GETHOSTBYNAME_R) && defined(__FreeBSD__)
+#undef HAVE_GETHOSTBYNAME_R
+#endif
+
 #ifdef HAVE_GETHOSTBYNAME_R
 
 void ei_init_resolve(void)
Index: lib/hipe/regalloc/Makefile
--- lib/hipe/regalloc/Makefile.orig	2017-06-20 20:56:09.000000000 +0200
+++ lib/hipe/regalloc/Makefile	2017-06-21 15:11:51.355287000 +0200
@@ -47,7 +47,6 @@
 	  hipe_node_sets hipe_spillcost hipe_reg_worklists \
 	  hipe_adj_list \
 	  hipe_temp_map \
-	  hipe_optimistic_regalloc \
 	  hipe_coalescing_regalloc \
 	  hipe_graph_coloring_regalloc \
 	  hipe_range_split \
Index: lib/tools/emacs/test.erl
Index: lib/wx/configure
--- lib/wx/configure.orig	2017-06-20 20:56:09.000000000 +0200
+++ lib/wx/configure	2017-06-21 15:11:51.356144000 +0200
@@ -4065,8 +4065,8 @@
 	CFLAGS="-g -Wall -fPIC $CFLAGS -fno-strict-aliasing"
 	;;
     *)
-	DEBUG_CFLAGS="-g -Wall -fPIC $CFLAGS -DDEBUG"
-	CFLAGS="-g -Wall -O2 -fPIC $CFLAGS -fomit-frame-pointer -fno-strict-aliasing"
+	DEBUG_CFLAGS="-fPIC $CFLAGS -DDEBUG"
+	CFLAGS="-O2 -fPIC $CFLAGS -fomit-frame-pointer -fno-strict-aliasing"
 	;;
 esac
 
