Project

General

Profile

Bug #15319

Since r65735, tool/mjit_archflag.sh related error on Solaris 10

Added by ngoto (Naohisa Goto) 10 months ago. Updated 10 months ago.

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

Description

r65735以降、手元の Solaris 10 上でのコンパイルがエラーになります。
コンパイラは gcc, Oracle Developer Studio のどちらでもダメでした。

r65738においてのgccでの最後の方のコンパイル時の出力を抜粋すると以下の通りです。

gcc -O -m64 -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include  -std=gnu99 -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   /usr/local/64/bin/gcc 
+ printf #define MJIT_CC_COMMON   
+ shift 
+ printf  "%s", /usr/local/64/bin/gcc 
+ echo 
+ quote MJIT_CFLAGS      MJIT_ARCHFLAG -w 
+ printf #define MJIT_CFLAGS      MJIT_ARCHFLAG 
+ shift 
+ printf  "%s", -w 
+ echo 
+ quote MJIT_OPTFLAGS    -O3 
+ printf #define MJIT_OPTFLAGS    
+ shift 
+ printf  "%s", -O3 
+ echo 
+ quote MJIT_DEBUGFLAGS  -ggdb3 
+ printf #define MJIT_DEBUGFLAGS  
+ shift 
+ printf  "%s", -ggdb3 
+ echo 
+ quote MJIT_LDSHARED    /usr/local/64/bin/gcc -shared 
+ printf #define MJIT_LDSHARED    
+ shift 
+ printf  "%s", /usr/local/64/bin/gcc -shared 
+ echo 
+ quote MJIT_DLDFLAGS    MJIT_ARCHFLAG -L/usr/local/64/lib -R/usr/local/64/lib 
+ printf #define MJIT_DLDFLAGS    MJIT_ARCHFLAG 
+ shift 
+ printf  "%s", -L/usr/local/64/lib -R/usr/local/64/lib 
+ echo 
+ quote MJIT_LIBS        -Wl,-rpath,/XXXXXXXXXX/lib -L/XXXXXXXXXX/lib 
+ printf #define MJIT_LIBS        
+ shift 
+ printf  "%s", -Wl,-rpath,/XXXXXXXXXX/lib -L/XXXXXXXXXX/lib 
+ echo 
+ quote PRELOADENV       "LD_PRELOAD_64" 
+ printf #define PRELOADENV       "LD_PRELOAD_64" 
+ shift 
+ echo 
+ } define_arch_flags 
/bin/sh: }: not found
+ echo 
+ echo #endif /* RUBY_MJIT_CONFIG_H */ 
gcc -O -m64 -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include  -std=gnu99 -D_XOPEN_SOURCE=600   -I. -I.ext/include/sparc64-solaris2.10 -I./include -I. -I./enc/unicode/10.0.0  -o mjit.o -c mjit.c
In file included from mjit.c:18:0:
mjit_worker.c:242:20: error: 'MJIT_ARCHFLAG' undeclared here (not in a function)
mjit_worker.c:242:20: error: expected '}' before string constant
mjit_worker.c:255:5: error: initializer element is not constant
mjit_worker.c:255:5: error: (near initialization for 'CC_DLDFLAGS_ARGS[0]')
mjit_worker.c:255:5: error: expected '}' before string constant
make: *** [mjit.o] Error 1

/bin/sh: }: not found というのがSolarisの/bin/shが出したエラーのようですが、これはMakefile.in (から作成されたMakefile)内の mjit_config.h を作成する部分の @{ に対応した } のような気がします。
もしかすると /bin/sh ではなく make 側の問題の可能性もあるでしょうか?

以下のバージョンのGNU Make を使っています。

$ /usr/local/bin/make --version
GNU Make 3.82
Built for sparc-sun-solaris2.10
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Related issues

Related to Ruby master - Bug #14876: /bin/sh: bad substitution since r63679 on SolarisClosedActions
Related to Ruby master - Bug #15328: mjit_worker.c fails to buildClosedActions

Associated revisions

Revision 3f84ef97
Added by nobu (Nobuyoshi Nakada) 10 months ago

fix for Solaris sh

  • Makefile.in (mjit_config.h): removed unnecessary assignment.

  • tool/mjit_archflag.sh (define_arch_flags): need to quote on
    Solaris. [ruby-dev:50669] [Bug #15319]

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

Revision 65808
Added by nobu (Nobuyoshi Nakada) 10 months ago

fix for Solaris sh

  • Makefile.in (mjit_config.h): removed unnecessary assignment.

  • tool/mjit_archflag.sh (define_arch_flags): need to quote on
    Solaris. [ruby-dev:50669] [Bug #15319]

Revision 65808
Added by nobu (Nobuyoshi Nakada) 10 months ago

fix for Solaris sh

  • Makefile.in (mjit_config.h): removed unnecessary assignment.

  • tool/mjit_archflag.sh (define_arch_flags): need to quote on
    Solaris. [ruby-dev:50669] [Bug #15319]

Revision 71ce60ce
Added by nobu (Nobuyoshi Nakada) 10 months ago

Makefile.in: get rid of local for Solaris sh

[ruby-dev:50673] [Bug #15319]

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

Revision 65902
Added by nobu (Nobuyoshi Nakada) 10 months ago

Makefile.in: get rid of local for Solaris sh

[ruby-dev:50673] [Bug #15319]

Revision 65902
Added by nobu (Nobuyoshi Nakada) 10 months ago

Makefile.in: get rid of local for Solaris sh

[ruby-dev:50673] [Bug #15319]

Revision 8a15e080
Added by nobu (Nobuyoshi Nakada) 10 months ago

mjit_archflag.sh: fix bare word in the header

[ruby-dev:50674] [Bug #15319]

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

Revision 65918
Added by nobu (Nobuyoshi Nakada) 10 months ago

mjit_archflag.sh: fix bare word in the header

[ruby-dev:50674] [Bug #15319]

Revision 65918
Added by nobu (Nobuyoshi Nakada) 10 months ago

mjit_archflag.sh: fix bare word in the header

[ruby-dev:50674] [Bug #15319]

History

#1

Updated by ngoto (Naohisa Goto) 10 months ago

  • Related to Bug #14876: /bin/sh: bad substitution since r63679 on Solaris added

Updated by ngoto (Naohisa Goto) 10 months ago

どうやら indent=$${archs+ } define_arch_flags; \ の行で/bin/shのエラーが発生しているようです。

つまり ${archs+ } の閉じ括弧が単体のコマンドとして認識されているようです。

Updated by nobu (Nobuyoshi Nakada) 10 months ago

これでどうでしょうか。

diff --git a/Makefile.in b/Makefile.in
index f1d5258ad9..b8db70f5c8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -601,7 +601,7 @@ mjit_config.h:
    quote "MJIT_DLDFLAGS    MJIT_ARCHFLAG" $(MJIT_DLDFLAGS); \
    quote "MJIT_LIBS       " $(LIBRUBYARG_SHARED); \
    quote 'PRELOADENV       "@PRELOADENV@"'; \
-   indent=$${archs+  } define_arch_flags; \
+   indent="$${archs+  }" define_arch_flags; \
    echo; \
    echo '#endif /* RUBY_MJIT_CONFIG_H */'; \
    } > $@
#4

Updated by nobu (Nobuyoshi Nakada) 10 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r65808.


fix for Solaris sh

  • Makefile.in (mjit_config.h): removed unnecessary assignment.

  • tool/mjit_archflag.sh (define_arch_flags): need to quote on
    Solaris. [ruby-dev:50669] [Bug #15319]

Updated by ngoto (Naohisa Goto) 10 months ago

  • Status changed from Closed to Open

r65808 の修正後、別のエラーになりました。(r65894で確認)

抜粋すると、bash等のローカル変数作成用の予約語 local がSolarisの/bin/shでは普通のコマンド扱いされています。

+ local indent= 
/bin/sh: local: not found

tool/mjit_archflag.sh の以下の行が原因と思われます。

define_arch_flags() {
    local indent=${archs:+'  '}
    ${archs:+echo} ${archs:+'#if 0'}

このスクリプトの現在の使われ方を見る限りは、 indent をグローバル変数にしても変わらない気がしますので、local を外して良いでしょうか?

Updated by nobu (Nobuyoshi Nakada) 10 months ago

Makefile.inの呼び出し側で indent=$${archs:+' '} define_arch_flags と渡すのはどうでしょうか。

#7

Updated by nobu (Nobuyoshi Nakada) 10 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r65902.


Makefile.in: get rid of local for Solaris sh

[ruby-dev:50673] [Bug #15319]

Updated by ngoto (Naohisa Goto) 10 months ago

  • Status changed from Closed to Open

r65902にて、シェルのエラーは出なくなったのですが、mjit_worker.cのコンパイルエラーは出続けています。

gcc -O -m64 -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include  -std=gnu99 -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   /usr/local/64/bin/gcc 
+ printf #define MJIT_CC_COMMON   
+ shift 
+ printf  "%s", /usr/local/64/bin/gcc 
+ echo 
+ quote MJIT_CFLAGS      MJIT_ARCHFLAG -w 
+ printf #define MJIT_CFLAGS      MJIT_ARCHFLAG 
+ shift 
+ printf  "%s", -w 
+ echo 
+ quote MJIT_OPTFLAGS    -O3 
+ printf #define MJIT_OPTFLAGS    
+ shift 
+ printf  "%s", -O3 
+ echo 
+ quote MJIT_DEBUGFLAGS  -ggdb3 
+ printf #define MJIT_DEBUGFLAGS  
+ shift 
+ printf  "%s", -ggdb3 
+ echo 
+ quote MJIT_LDSHARED    /usr/local/64/bin/gcc -shared 
+ printf #define MJIT_LDSHARED    
+ shift 
+ printf  "%s", /usr/local/64/bin/gcc -shared 
+ echo 
+ quote MJIT_DLDFLAGS    MJIT_ARCHFLAG -L/usr/local/64/lib -R/usr/local/64/lib 
+ printf #define MJIT_DLDFLAGS    MJIT_ARCHFLAG 
+ shift 
+ printf  "%s", -L/usr/local/64/lib -R/usr/local/64/lib 
+ echo 
+ quote MJIT_LIBS        -Wl,-rpath,/XXXXX/sparc64-gcc-trunk/lib -L/XXXXX/sparc64-gcc-trunk/lib 
+ printf #define MJIT_LIBS        
+ shift 
+ printf  "%s", -Wl,-rpath,/XXXXX/sparc64-gcc-trunk/lib -L/XXXXX/sparc64-gcc-trunk/lib 
+ echo 
+ quote PRELOADENV       "LD_PRELOAD_64" 
+ printf #define PRELOADENV       "LD_PRELOAD_64" 
+ shift 
+ echo 
indent=
+ define_arch_flags 
+ quote MJIT_ARCHFLAG   -m64 -m64 
+ printf #define MJIT_ARCHFLAG   -m64 
+ shift 
+ printf  "%s", -m64 
+ echo 
+ echo 
+ echo #endif /* RUBY_MJIT_CONFIG_H */ 
gcc -O -m64 -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include  -std=gnu99 -D_XOPEN_SOURCE=600   -I. -I.ext/include/sparc64-solaris2.10 -I./include -I. -I./enc/unicode/10.0.0  -o mjit.o -c mjit.c
In file included from mjit.c:18:0:
mjit_worker.c:248:20: error: 'm64' undeclared here (not in a function)
mjit_worker.c:248:20: error: expected '}' before string constant
mjit_worker.c:261:5: error: wrong type argument to unary minus
mjit_worker.c:261:5: error: initializer element is not constant
mjit_worker.c:261:5: error: (near initialization for 'CC_DLDFLAGS_ARGS[0]')
mjit_worker.c:261:5: error: expected '}' before string constant
make: *** [mjit.o] Error 1

mjit_config.h の中身は以下の通りです。

#ifndef RUBY_MJIT_CONFIG_H
#define RUBY_MJIT_CONFIG_H 1

#define MJIT_MIN_HEADER_NAME "/include/ruby-2.6.0/sparc64-solaris2.10/rb_mjit_min_header-2.6.0.h"
#define MJIT_CC_COMMON   "/usr/local/64/bin/gcc",
#define MJIT_CFLAGS      MJIT_ARCHFLAG "-w",
#define MJIT_OPTFLAGS    "-O3",
#define MJIT_DEBUGFLAGS  "-ggdb3",
#define MJIT_LDSHARED    "/usr/local/64/bin/gcc", "-shared",
#define MJIT_DLDFLAGS    MJIT_ARCHFLAG "-L/usr/local/64/lib", "-R/usr/local/64/lib",
#define MJIT_LIBS        "-Wl,-rpath,/XXXXX/sparc64-gcc-trunk/lib", "-L/XXXXX/sparc64-gcc-trunk/lib",
#define PRELOADENV       "LD_PRELOAD_64"
#define MJIT_ARCHFLAG   -m64 "-m64",

#endif /* RUBY_MJIT_CONFIG_H */

上記の末尾から3行目の #define MJIT_ARCHFLAG -m64 "-m64", に含まれるダブルクオートで囲まれない素の-m64がエラーの原因と思います。

この部分は tool/mjit_archflag.sh の以下の行で生成されたように見えます。
この行の ${arch_flag:- /* no flag */} の部分が、ダブルクオートで囲まれない -m64 が出力される直接の原因と思われます。
このコードは、$arch_flagが空のときに /* no flag */ を出力させたい意図で書かれたのは何となくわかるのですが、$arch_flagに値がセットされているときには何を出力させたかったのでしょうか?

    quote "MJIT_ARCHFLAG   ${arch_flag:- /* no flag */}" ${arch_flag}
#9

Updated by nobu (Nobuyoshi Nakada) 10 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r65918.


mjit_archflag.sh: fix bare word in the header

[ruby-dev:50674] [Bug #15319]

#10

Updated by nobu (Nobuyoshi Nakada) 10 months ago

  • Related to Bug #15328: mjit_worker.c fails to build added

Also available in: Atom PDF