Project

General

Profile

Bug #14876

/bin/sh: bad substitution since r63679 on Solaris

Added by ngoto (Naohisa Goto) about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-dev:50583]

Description

r63679以降、Solaris 上にて 64ビットでコンパイルすると、
mjit_config.h 作成中に以下のように "/bin/sh: bad substitution" エラーになります。

32ビットコンパイルでは発生しません。(rubyci.orgのSolarisは32ビットのみ)

r63679 で変更された部分が原因と思われますが、シェルとmakeの変数が複雑に入り乱れているため切り分けができていません。

cc -errtags=yes  -xO4 -xtarget=sparc64xplus -m64 -DRUBY_DEVEL=1 -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include  -D_XOPEN_SOURCE=600   -I. -I.ext/include/sparc64-solaris2.10 -I./include -I. -I./enc/unicode/10.0.0 -o math.o -c math.c
+ echo #ifndef RUBY_MJIT_CONFIG_H 
+ echo #define RUBY_MJIT_CONFIG_H 1 
+ echo 
sep=
+ quote MJIT_MIN_HEADER_NAME /include/ruby-2.6.0/sparc64-solaris2.10/rb_mjit_min_header-2.6.0.h 
+ printf #define MJIT_MIN_HEADER_NAME 
+ shift 
+ printf  "%s" /include/ruby-2.6.0/sparc64-solaris2.10/rb_mjit_min_header-2.6.0.h 
+ echo 
sep=,
+ quote MJIT_CC_COMMON   cc 
+ printf #define MJIT_CC_COMMON   
+ shift 
+ printf  "%s", cc 
+ echo 
+ quote MJIT_CFLAGS      MJIT_ARCHFLAG -w 
+ printf #define MJIT_CFLAGS      MJIT_ARCHFLAG 
+ shift 
+ printf  "%s", -w 
+ echo 
+ quote MJIT_OPTFLAGS    
+ printf #define MJIT_OPTFLAGS    
+ shift 
+ echo 
+ quote MJIT_DEBUGFLAGS  -g 
+ printf #define MJIT_DEBUGFLAGS  
+ shift 
+ printf  "%s", -g 
+ echo 
+ quote MJIT_LDSHARED    cc -G 
+ printf #define MJIT_LDSHARED    
+ shift 
+ printf  "%s", cc -G 
+ echo 
+ quote MJIT_DLDFLAGS    MJIT_ARCHFLAG -m64 -L/usr/local/64/lib -R/usr/local/64/lib 
+ printf #define MJIT_DLDFLAGS    MJIT_ARCHFLAG 
+ shift 
+ printf  "%s", -m64 -L/usr/local/64/lib -R/usr/local/64/lib 
+ echo 
+ quote MJIT_LIBS        -L/XXXXXXXXXX/lib 
+ printf #define MJIT_LIBS        
+ shift 
+ printf  "%s", -L/XXXXXXXXXX/lib 
+ echo 
+ echo #if 0 
/bin/sh: bad substitution
make: *** [mjit_config.h] Error 1

Related issues

Related to Ruby master - Bug #15319: Since r65735, tool/mjit_archflag.sh related error on Solaris 10ClosedActions

Associated revisions

Revision 2c68033a
Added by ngoto (Naohisa Goto) about 1 year ago

Makefile.in: ARCH_FLAG may contain "-m64" etc.

  • Makefile.in (mjit_config.h): ARCH_FLAG may contain "-m64", "-m32", "-march=i486" and so on, but the change made with r63232 only supports "-arch AAA -arch BBB" mainly used on Mac OS X. To solve the issue, ARCH_FLAG is parsed and the architectures specified in "-arch XXX" are added to $archs and the rest is stored to $arch_flag. The $arch_flag is defined as MJIT_ARCHFLAG if $archs is empty or the target architecture is not listed in $arch. Fix build failure on Solaris 10 with ./configure CFLAGS="-m64". [Bug #14876] [ruby-dev:50583]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63828
Added by ngoto (Naohisa Goto) about 1 year ago

Makefile.in: ARCH_FLAG may contain "-m64" etc.

  • Makefile.in (mjit_config.h): ARCH_FLAG may contain "-m64", "-m32", "-march=i486" and so on, but the change made with r63232 only supports "-arch AAA -arch BBB" mainly used on Mac OS X. To solve the issue, ARCH_FLAG is parsed and the architectures specified in "-arch XXX" are added to $archs and the rest is stored to $arch_flag. The $arch_flag is defined as MJIT_ARCHFLAG if $archs is empty or the target architecture is not listed in $arch. Fix build failure on Solaris 10 with ./configure CFLAGS="-m64". [Bug #14876] [ruby-dev:50583]

Revision 63828
Added by ngoto (Naohisa Goto) about 1 year ago

Makefile.in: ARCH_FLAG may contain "-m64" etc.

  • Makefile.in (mjit_config.h): ARCH_FLAG may contain "-m64", "-m32", "-march=i486" and so on, but the change made with r63232 only supports "-arch AAA -arch BBB" mainly used on Mac OS X. To solve the issue, ARCH_FLAG is parsed and the architectures specified in "-arch XXX" are added to $archs and the rest is stored to $arch_flag. The $arch_flag is defined as MJIT_ARCHFLAG if $archs is empty or the target architecture is not listed in $arch. Fix build failure on Solaris 10 with ./configure CFLAGS="-m64". [Bug #14876] [ruby-dev:50583]

History

Updated by ngoto (Naohisa Goto) about 1 year ago

r63232 で追加された ${arch%=*} が "bad substitution" の原因でした。
前後の部分を引用します。

       $${archs:+echo} $${archs:+'#if 0'}; \
       for arch in $$archs; do \
           echo "#elif defined __$${arch%=*}__"; \
           quote "  MJIT_ARCHFLAG " -arch $${arch%=*}; \
       done; \
       $${archs:+echo} $${archs:+'#endif'}; \

従来、archs に値が入っていなかったのでforループには突入しなかったのが、
r63679 の変更で archs に値が入るようになって、露見したようです。

Updated by ngoto (Naohisa Goto) about 1 year ago

r63679 で Makefile.in の562行目に追加された archs="$${archs:-$(ARCH_FLAG:-arch=)}"; が悪さをしているようです。
この行は、Makefileの置換とシェルの置換が混ざっていて極めてわかりにくいのですが、
ARCH_FLAG="-arch i386 -arch x86_64" などが入っているとき「だけ」しか考慮されておらず、
ARCH_FLAG="-m64" や ARCH_FLAG="-march=i486" のときは想定外のようです。

ARCH_FLAG="-m64" のときは、mjit_config.h の末尾に以下が追加されることになります。
(シェルの ${arch%=*} の置換は正常に行われたと仮定)

#if 0
#elif defined __-m64__
#define   MJIT_ARCHFLAG  "-arch", "-m64",
#endif

この #elif defined __-m64__ というのはCのマクロとして明らかに異常と思いますし、
#define MJIT_ARCHFLAG "-arch", "-m64", というのも、 gcc のオプションとしてエラーになると思います。

#3

Updated by ngoto (Naohisa Goto) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r63828.


Makefile.in: ARCH_FLAG may contain "-m64" etc.

  • Makefile.in (mjit_config.h): ARCH_FLAG may contain "-m64", "-m32", "-march=i486" and so on, but the change made with r63232 only supports "-arch AAA -arch BBB" mainly used on Mac OS X. To solve the issue, ARCH_FLAG is parsed and the architectures specified in "-arch XXX" are added to $archs and the rest is stored to $arch_flag. The $arch_flag is defined as MJIT_ARCHFLAG if $archs is empty or the target architecture is not listed in $arch. Fix build failure on Solaris 10 with ./configure CFLAGS="-m64". [Bug #14876] [ruby-dev:50583]
#4

Updated by ngoto (Naohisa Goto) 8 months ago

  • Related to Bug #15319: Since r65735, tool/mjit_archflag.sh related error on Solaris 10 added

Also available in: Atom PDF