Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#!/bin/sh fails for Solaris #25845

Closed
bcxorg opened this issue May 27, 2015 · 5 comments · Fixed by #39857
Closed

#!/bin/sh fails for Solaris #25845

bcxorg opened this issue May 27, 2015 · 5 comments · Fixed by #39857

Comments

@bcxorg
Copy link

bcxorg commented May 27, 2015

The configure script begins with:

!/bin/sh

This works on machines where bash implements its own version of sh. But fails on Solaris where sh and bash are separated programs. To fix, I changed that first line into:

!/bin/bash

And after that it ran.

@sanxiyn
Copy link
Member

sanxiyn commented May 28, 2015

cf. #21000.

@brson
Copy link
Contributor

brson commented Jun 1, 2015

If the problem here is that we are using bashisms in the configure script, I would rather fix that.

@steveklabnik
Copy link
Member

sh configure works for me today. Was this issue fixed? I remember some other issues...

bors added a commit that referenced this issue Jan 31, 2016
This pull request adds support for [Illumos](http://illumos.org/)-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846.

Required changes in libc are already merged: rust-lang/libc#138

Here's a snapshot required to build a stage0 compiler:
https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz
It passes all checks from `make check`.

There are some changes I'm not quite sure about, e.g. macro usage in `src/libstd/num/f64.rs` and `DirEntry` structure in `src/libstd/sys/unix/fs.rs`, so any comments on how to rewrite it better would be greatly appreciated.

Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409

Thanks!

r? @brson
bors added a commit that referenced this issue Feb 3, 2016
This pull request adds support for [Illumos](http://illumos.org/)-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846.

Required changes in libc are already merged: rust-lang/libc#138

Here's a snapshot required to build a stage0 compiler:
https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz
It passes all checks from `make check`.

There are some changes I'm not quite sure about, e.g. macro usage in `src/libstd/num/f64.rs` and `DirEntry` structure in `src/libstd/sys/unix/fs.rs`, so any comments on how to rewrite it better would be greatly appreciated.

Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409

Thanks!

r? @brson
@vojtechkral
Copy link
Contributor

configure works, but the installer has the same issue. For this reason, make install doesn't work on Solaris.

@binarycrusader
Copy link
Contributor

@brson

If the problem here is that we are using bashisms in the configure script, I would rather fix that.

According to shellcheck.net, as one example, gen-installer.sh is using bashsims or other shell extensions:

$ shellcheck myscriptshellcheck.net
 
Line 34:
    if [ $? -ne 0 ]
         ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
 
Line 41:
    if command -v $1 >/dev/null 2>&1
                  ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 48:
    local t
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 49:
    local tlen
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 50:
    eval t=\$$1
             ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 51:
    eval tlen=\${#$1}
                ^-- SC1083: This { is literal. Check expression (missing ;/\n?) or quote it.
                  ^-- SC2086: Double quote to prevent globbing and word splitting.
                    ^-- SC1083: This } is literal. Check expression (missing ;/\n?) or quote it.
 
Line 52:
    if [ $tlen -gt 35 ]
         ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 54:
        printf "gen-installer: %-20s := %.35s ...\n" $1 "$t"
                                                     ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 56:
        printf "gen-installer: %-20s := %s %s\n" $1 "$t"
               ^-- SC2183: This format string has 3 variables, but is passed 2 arguments.
                                                 ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 63:
    local op=$1
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 64:
    local default=$2
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 67:
    local doc="$*"
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 68:
    if [ $HELP -eq 0 ]
         ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 70:
        local uop=$(echo $op | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
        ^-- SC2039: In POSIX sh, 'local' is undefined.
              ^-- SC2155: Declare and assign separately to avoid masking return values.
                         ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 71:
        local v="CFG_${uop}"
        ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 72:
        eval $v="$default"
             ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 77:
                local val=$(echo "$arg" | cut -f2 -d=)
                ^-- SC2039: In POSIX sh, 'local' is undefined.
                      ^-- SC2155: Declare and assign separately to avoid masking return values.
 
Line 78:
                eval $v=$val
                     ^-- SC2086: Double quote to prevent globbing and word splitting.
                        ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 81:
        putvar $v
               ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 95:
    local op=$1
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 96:
    local default=$2
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 99:
    local doc="$*"
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 100:
    local flag=""
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 102:
    if [ $default -eq 0 ]
         ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 110:
    if [ $HELP -eq 0 ]
         ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 116:
                op=$(echo $op | tr 'a-z-' 'A-Z_')
                          ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 117:
                flag=$(echo $flag | tr 'a-z' 'A-Z')
                                       ^-- SC2018: Use '[:lower:]' to support accents and foreign alphabets.
                                             ^-- SC2019: Use '[:upper:]' to support accents and foreign alphabets.
 
Line 118:
                local v="CFG_${flag}_${op}"
                ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 119:
                eval $v=1
                     ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 120:
                putvar $v
                       ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 135:
    local op=$1
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 137:
    local doc="$*"
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 139:
    if [ $HELP -eq 0 ]
         ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 145:
                op=$(echo $op | tr 'a-z-' 'A-Z_')
                          ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 146:
                local v="CFG_${op}"
                ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 147:
                eval $v=1
                     ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 148:
                putvar $v
                       ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 163:
        local is_arg_valid=0
        ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 166:
            if test --disable-$option = $arg
                              ^-- SC2086: Double quote to prevent globbing and word splitting.
                                        ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 170:
            if test --enable-$option = $arg
                             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                       ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 174:
            if test --$option = $arg
                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                                ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 203:
    local path="$1"
    ^-- SC2039: In POSIX sh, 'local' is undefined.
 
Line 221:
CFG_ARGS="$@"
         ^-- SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
 
Line 237:
OPTIONS=""
^-- SC2034: OPTIONS appears unused. Verify it or export it.
 
Line 262:
src_dir="$(abs_path $(dirname "$0"))"
                    ^-- SC2046: Quote this to prevent word splitting.
 
Line 264:
rust_installer_version=`cat "$src_dir/rust-installer-version"`
                       ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 274:
rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
       ^-- SC2115: Use "${var:?}" to ensure this never expands to / .
 
Line 284:
manifest=`(cd "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$CFG_COMPONENT_NAME" && find . -type f | sed 's/^\.\///') | sort`
         ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 287:
bulk_dirs=`echo "$CFG_BULK_DIRS" | tr "," " "`
          ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 289:
    bulk_dir=`echo "$bulk_dir" | sed s/\\\//\\\\\\\\\\\//g`
             ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 290:
    manifest=`echo "$manifest" | sed /^$bulk_dir/d`
             ^-- SC2006: Use $(..) instead of legacy `..`.
                                       ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 294:
manifest=`echo "$manifest" | sed /^$/d | sed s/^/file:/`
         ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 298:
    manifest=`echo "$manifest" && echo "dir:$bulk_dir"`
             ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 303:
manifest=`echo "$manifest" | sed /^$/d`
         ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 320:
    overlay_files=`(cd "$CFG_NON_INSTALLED_OVERLAY" && find . -type f)`
                  ^-- SC2006: Use $(..) instead of legacy `..`.

$ 

But in all honesty, I don't think it's worth it. I would encourage you to either rewrite the script in Python (such that it is compatible with Python 2.x and 3.x) or simply change the scripts to use #!/bin/bash instead. On Solaris, /bin/sh is the traditional bourne shell, not bash, and is not even POSIX compliant. This is for backwards-compatibility reasons, among others. The posix shell is /usr/xpg4/bin/sh.

binarycrusader added a commit to binarycrusader/rust that referenced this issue Feb 15, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Feb 16, 2017
use bash when invoking dist shell scripts on solaris

Partially fixes rust-lang#25845

A separate, trivial fix is needed to the rust-installer scripts to completely resolve this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants