Skip to content

Instantly share code, notes, and snippets.

@knu
Last active January 2, 2016 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knu/8330662 to your computer and use it in GitHub Desktop.
Save knu/8330662 to your computer and use it in GitHub Desktop.
ruby 2.1/trunk fails to build with clang when configured with --with-opt-dir
  • configure に --with-opt-dir=/opt/local を指定する

  • checking for printf prefix for long long... が、 clang の吐く clang: warning: argument unused during compilation: '-I /opt/local/include' のせいで失敗し、 config.h に PRI_LL_PREFIX の定義が入らない

  • compiling .../ext/-test-/num2int/num2int.c がこけてビルド失敗

  • 以下で直るが、clangでサポートされないフラグまで無警告になるのが副作用

Index: configure.in
===================================================================
--- configure.in	(revision 44533)
+++ configure.in	(working copy)
@@ -746,6 +746,7 @@ if test "$GCC:${warnflags+set}:no" = yes
 		 -Werror=implicit-function-declaration \
 		 -Werror=division-by-zero \
 		 -Werror=deprecated-declarations \
+		 -Qunused-arguments \
 		 $extra_warning \
 		 ; do
 	if test "$particular_werror_flags" != yes; then
  • 影響範囲を限定するならこうか
Index: configure.in
===================================================================
--- configure.in	(revision 45371)
+++ configure.in	(working copy)
@@ -779,6 +779,8 @@ if test "$GCC:${warnflags+set}:no" = yes
     rb_cv_warnflags="$warnflags"
     warnflags=
 fi
+RUBY_TRY_CFLAGS(-Qunused-arguments, [RUBY_APPEND_OPTIONS(rb_cv_wsuppress_flags, -Qunused-arguments)])
+
 if test "$GCC" = yes; then
     # -D_FORTIFY_SOURCE
     # When defined _FORTIFY_SOURCE, glibc enables some additional sanity
@@ -1302,7 +1304,8 @@ AC_DEFINE_UNQUOTED(PACKED_STRUCT_UNALIGN
 AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [
 AC_CACHE_CHECK([for printf prefix for $1], [rb_cv_pri_prefix_]AS_TR_SH($1),[
     [rb_cv_pri_prefix_]AS_TR_SH($1)=[NONE]
-    RUBY_WERROR_FLAG(for pri in $2; do
+    RUBY_WERROR_FLAG(RUBY_APPEND_OPTIONS(CFLAGS, $rb_cv_wsuppress_flags)
+    for pri in $2; do
         AC_TRY_COMPILE(
             [@%:@include <stdio.h>
 	    @%:@include <stddef.h>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment