Skip to content

Commit bfd2f5b

Browse files
committed
configure: Remove --build detection
This commit removes detection of CFG_OSTYPE and CFG_CPUTYPE from the configure script, which means that the default value of `--build` is no longer present in the configure script. All this logic is now available in rustbuild itself, so there's no need to duplicate it.
1 parent 49a5aa4 commit bfd2f5b

File tree

3 files changed

+23
-209
lines changed

3 files changed

+23
-209
lines changed

configure

Lines changed: 1 addition & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -384,207 +384,6 @@ need_cmd sed
384384
need_cmd file
385385
need_cmd make
386386

387-
msg "inspecting environment"
388-
389-
CFG_OSTYPE=$(uname -s)
390-
CFG_CPUTYPE=$(uname -m)
391-
392-
if [ $CFG_OSTYPE = Darwin -a $CFG_CPUTYPE = i386 ]
393-
then
394-
# Darwin's `uname -s` lies and always returns i386. We have to use sysctl
395-
# instead.
396-
if sysctl hw.optional.x86_64 | grep -q ': 1'
397-
then
398-
CFG_CPUTYPE=x86_64
399-
fi
400-
fi
401-
402-
# The goal here is to come up with the same triple as LLVM would,
403-
# at least for the subset of platforms we're willing to target.
404-
405-
case $CFG_OSTYPE in
406-
407-
Linux)
408-
CFG_OSTYPE=unknown-linux-gnu
409-
;;
410-
411-
FreeBSD)
412-
CFG_OSTYPE=unknown-freebsd
413-
;;
414-
415-
DragonFly)
416-
CFG_OSTYPE=unknown-dragonfly
417-
;;
418-
419-
Bitrig)
420-
CFG_OSTYPE=unknown-bitrig
421-
;;
422-
423-
OpenBSD)
424-
CFG_OSTYPE=unknown-openbsd
425-
;;
426-
427-
NetBSD)
428-
CFG_OSTYPE=unknown-netbsd
429-
;;
430-
431-
Darwin)
432-
CFG_OSTYPE=apple-darwin
433-
;;
434-
435-
SunOS)
436-
CFG_OSTYPE=sun-solaris
437-
CFG_CPUTYPE=$(isainfo -n)
438-
;;
439-
440-
Haiku)
441-
CFG_OSTYPE=unknown-haiku
442-
;;
443-
444-
MINGW*)
445-
# msys' `uname` does not print gcc configuration, but prints msys
446-
# configuration. so we cannot believe `uname -m`:
447-
# msys1 is always i686 and msys2 is always x86_64.
448-
# instead, msys defines $MSYSTEM which is MINGW32 on i686 and
449-
# MINGW64 on x86_64.
450-
CFG_CPUTYPE=i686
451-
CFG_OSTYPE=pc-windows-gnu
452-
if [ "$MSYSTEM" = MINGW64 ]
453-
then
454-
CFG_CPUTYPE=x86_64
455-
fi
456-
;;
457-
458-
MSYS*)
459-
CFG_OSTYPE=pc-windows-gnu
460-
;;
461-
462-
# Thad's Cygwin identifiers below
463-
464-
# Vista 32 bit
465-
CYGWIN_NT-6.0)
466-
CFG_OSTYPE=pc-windows-gnu
467-
CFG_CPUTYPE=i686
468-
;;
469-
470-
# Vista 64 bit
471-
CYGWIN_NT-6.0-WOW64)
472-
CFG_OSTYPE=pc-windows-gnu
473-
CFG_CPUTYPE=x86_64
474-
;;
475-
476-
# Win 7 32 bit
477-
CYGWIN_NT-6.1)
478-
CFG_OSTYPE=pc-windows-gnu
479-
CFG_CPUTYPE=i686
480-
;;
481-
482-
# Win 7 64 bit
483-
CYGWIN_NT-6.1-WOW64)
484-
CFG_OSTYPE=pc-windows-gnu
485-
CFG_CPUTYPE=x86_64
486-
;;
487-
488-
# Win 8 # uname -s on 64-bit cygwin does not contain WOW64, so simply use uname -m to detect arch (works in my install)
489-
CYGWIN_NT-6.3)
490-
CFG_OSTYPE=pc-windows-gnu
491-
;;
492-
# We do not detect other OS such as XP/2003 using 64 bit using uname.
493-
# If we want to in the future, we will need to use Cygwin - Chuck's csih helper in /usr/lib/csih/winProductName.exe or alternative.
494-
*)
495-
err "unknown OS type: $CFG_OSTYPE"
496-
;;
497-
esac
498-
499-
500-
case $CFG_CPUTYPE in
501-
502-
i386 | i486 | i686 | i786 | x86)
503-
CFG_CPUTYPE=i686
504-
;;
505-
506-
xscale | arm)
507-
CFG_CPUTYPE=arm
508-
;;
509-
510-
armv6l)
511-
CFG_CPUTYPE=arm
512-
CFG_OSTYPE="${CFG_OSTYPE}eabihf"
513-
;;
514-
515-
armv7l)
516-
CFG_CPUTYPE=armv7
517-
CFG_OSTYPE="${CFG_OSTYPE}eabihf"
518-
;;
519-
520-
aarch64 | arm64)
521-
CFG_CPUTYPE=aarch64
522-
;;
523-
524-
powerpc | ppc)
525-
CFG_CPUTYPE=powerpc
526-
;;
527-
528-
powerpc64 | ppc64)
529-
CFG_CPUTYPE=powerpc64
530-
;;
531-
532-
powerpc64le | ppc64le)
533-
CFG_CPUTYPE=powerpc64le
534-
;;
535-
536-
s390x)
537-
CFG_CPUTYPE=s390x
538-
;;
539-
540-
x86_64 | x86-64 | x64 | amd64)
541-
CFG_CPUTYPE=x86_64
542-
;;
543-
544-
mips | mips64)
545-
if [ "$CFG_CPUTYPE" = "mips64" ]; then
546-
CFG_OSTYPE="${CFG_OSTYPE}abi64"
547-
fi
548-
ENDIAN=$(printf '\1' | od -dAn)
549-
if [ "$ENDIAN" -eq 1 ]; then
550-
CFG_CPUTYPE="${CFG_CPUTYPE}el"
551-
elif [ "$ENDIAN" -ne 256 ]; then
552-
err "unknown endianness: $ENDIAN (expecting 1 for little or 256 for big)"
553-
fi
554-
;;
555-
556-
BePC)
557-
CFG_CPUTYPE=i686
558-
;;
559-
560-
*)
561-
err "unknown CPU type: $CFG_CPUTYPE"
562-
esac
563-
564-
# Detect 64 bit linux systems with 32 bit userland and force 32 bit compilation
565-
if [ $CFG_OSTYPE = unknown-linux-gnu -a $CFG_CPUTYPE = x86_64 ]
566-
then
567-
# $SHELL does not exist in standard 'sh', so probably only exists
568-
# if configure is running in an interactive bash shell. /usr/bin/env
569-
# exists *everywhere*.
570-
BIN_TO_PROBE="$SHELL"
571-
if [ ! -r "$BIN_TO_PROBE" ]; then
572-
if [ -r "/usr/bin/env" ]; then
573-
BIN_TO_PROBE="/usr/bin/env"
574-
else
575-
warn "Cannot check if the userland is i686 or x86_64"
576-
fi
577-
fi
578-
file -L "$BIN_TO_PROBE" | grep -q "x86[_-]64"
579-
if [ $? != 0 ]; then
580-
msg "i686 userland on x86_64 Linux kernel"
581-
CFG_CPUTYPE=i686
582-
fi
583-
fi
584-
585-
586-
DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}"
587-
588387
CFG_SRC_DIR="$(abs_path $(dirname $0))/"
589388
CFG_SRC_DIR_RELATIVE="$(dirname $0)/"
590389
CFG_BUILD_DIR="$(pwd)/"
@@ -672,7 +471,7 @@ valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
672471
valopt llvm-root "" "set LLVM root"
673472
valopt python "" "set path to python"
674473
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
675-
valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
474+
valopt build "" "GNUs ./configure syntax LLVM build triple"
676475
valopt android-cross-path "" "Android NDK standalone path (deprecated)"
677476
valopt i686-linux-android-ndk "" "i686-linux-android NDK standalone path"
678477
valopt arm-linux-androideabi-ndk "" "arm-linux-androideabi NDK standalone path"

src/bootstrap/bootstrap.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,10 @@ def get_toml(self, key):
295295

296296
def get_mk(self, key):
297297
for line in iter(self.config_mk.splitlines()):
298-
if line.startswith(key):
299-
return line[line.find(':=') + 2:].strip()
298+
if line.startswith(key + ' :='):
299+
var = line[line.find(':=') + 2:].strip()
300+
if var != '':
301+
return var
300302
return None
301303

302304
def cargo(self):
@@ -437,6 +439,8 @@ def build_triple(self):
437439
sys.exit(err)
438440
elif ostype == 'Darwin':
439441
ostype = 'apple-darwin'
442+
elif ostype == 'Haiku':
443+
ostype = 'unknown-haiku'
440444
elif ostype.startswith('MINGW'):
441445
# msys' `uname` does not print gcc configuration, but prints msys
442446
# configuration. so we cannot believe `uname -m`:
@@ -464,9 +468,12 @@ def build_triple(self):
464468
cputype = 'i686'
465469
elif cputype in {'xscale', 'arm'}:
466470
cputype = 'arm'
467-
elif cputype == 'armv7l':
471+
elif cputype == 'armv6l':
468472
cputype = 'arm'
469473
ostype += 'eabihf'
474+
elif cputype == 'armv7l':
475+
cputype = 'armv7'
476+
ostype += 'eabihf'
470477
elif cputype == 'aarch64':
471478
cputype = 'aarch64'
472479
elif cputype == 'arm64':
@@ -487,12 +494,20 @@ def build_triple(self):
487494
raise ValueError('unknown byteorder: ' + sys.byteorder)
488495
# only the n64 ABI is supported, indicate it
489496
ostype += 'abi64'
490-
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
497+
elif cputype in {'powerpc', 'ppc'}:
491498
cputype = 'powerpc'
499+
elif cputype in {'powerpc64', 'ppc64'}:
500+
cputype = 'powerpc64'
501+
elif cputype in {'powerpc64le', 'ppc64le'}:
502+
cputype = 'powerpc64le'
492503
elif cputype == 'sparcv9':
493504
pass
494505
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
495506
cputype = 'x86_64'
507+
elif cputype == 's390x':
508+
cputype = 's390x'
509+
elif cputype == 'BePC':
510+
cputype = 'i686'
496511
else:
497512
err = "unknown cpu type: " + cputype
498513
if self.verbose:

src/bootstrap/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,12 @@ impl Config {
456456
}
457457

458458
match key {
459-
"CFG_BUILD" => self.build = value.to_string(),
460-
"CFG_HOST" => {
459+
"CFG_BUILD" if value.len() > 0 => self.build = value.to_string(),
460+
"CFG_HOST" if value.len() > 0 => {
461461
self.host = value.split(" ").map(|s| s.to_string())
462462
.collect();
463463
}
464-
"CFG_TARGET" => {
464+
"CFG_TARGET" if value.len() > 0 => {
465465
self.target = value.split(" ").map(|s| s.to_string())
466466
.collect();
467467
}

0 commit comments

Comments
 (0)