Skip to content

Commit f8ca805

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 51a4238 commit f8ca805

File tree

3 files changed

+27
-214
lines changed

3 files changed

+27
-214
lines changed

configure

+1-202
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 | armv8l)
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)/"
@@ -673,7 +472,7 @@ valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
673472
valopt llvm-root "" "set LLVM root"
674473
valopt python "" "set path to python"
675474
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
676-
valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
475+
valopt build "" "GNUs ./configure syntax LLVM build triple"
677476
valopt android-cross-path "" "Android NDK standalone path (deprecated)"
678477
valopt i686-linux-android-ndk "" "i686-linux-android NDK standalone path"
679478
valopt arm-linux-androideabi-ndk "" "arm-linux-androideabi NDK standalone path"

src/bootstrap/bootstrap.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,10 @@ def get_toml(self, key):
296296

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

303305
def cargo(self):
@@ -438,6 +440,8 @@ def build_triple(self):
438440
sys.exit(err)
439441
elif ostype == 'Darwin':
440442
ostype = 'apple-darwin'
443+
elif ostype == 'Haiku':
444+
ostype = 'unknown-haiku'
441445
elif ostype.startswith('MINGW'):
442446
# msys' `uname` does not print gcc configuration, but prints msys
443447
# configuration. so we cannot believe `uname -m`:
@@ -465,9 +469,12 @@ def build_triple(self):
465469
cputype = 'i686'
466470
elif cputype in {'xscale', 'arm'}:
467471
cputype = 'arm'
468-
elif cputype in {'armv7l', 'armv8l'}:
472+
elif cputype in {'armv6l', 'armv7l', 'armv8l'}:
469473
cputype = 'arm'
470474
ostype += 'eabihf'
475+
elif cputype == 'armv7l':
476+
cputype = 'armv7'
477+
ostype += 'eabihf'
471478
elif cputype == 'aarch64':
472479
cputype = 'aarch64'
473480
elif cputype == 'arm64':
@@ -488,12 +495,20 @@ def build_triple(self):
488495
raise ValueError('unknown byteorder: ' + sys.byteorder)
489496
# only the n64 ABI is supported, indicate it
490497
ostype += 'abi64'
491-
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
498+
elif cputype in {'powerpc', 'ppc'}:
492499
cputype = 'powerpc'
500+
elif cputype in {'powerpc64', 'ppc64'}:
501+
cputype = 'powerpc64'
502+
elif cputype in {'powerpc64le', 'ppc64le'}:
503+
cputype = 'powerpc64le'
493504
elif cputype == 'sparcv9':
494505
pass
495506
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
496507
cputype = 'x86_64'
508+
elif cputype == 's390x':
509+
cputype = 's390x'
510+
elif cputype == 'BePC':
511+
cputype = 'i686'
497512
else:
498513
err = "unknown cpu type: " + cputype
499514
if self.verbose:

src/bootstrap/config.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,13 @@ impl Config {
463463
}
464464

465465
match key {
466-
"CFG_BUILD" => self.build = value.to_string(),
467-
"CFG_HOST" => {
468-
self.host = value.split(" ").map(|s| s.to_string())
469-
.collect();
470-
}
471-
"CFG_TARGET" => {
472-
self.target = value.split(" ").map(|s| s.to_string())
473-
.collect();
466+
"CFG_BUILD" if value.len() > 0 => self.build = value.to_string(),
467+
"CFG_HOST" if value.len() > 0 => {
468+
self.host.extend(value.split(" ").map(|s| s.to_string()));
469+
470+
}
471+
"CFG_TARGET" if value.len() > 0 => {
472+
self.target.extend(value.split(" ").map(|s| s.to_string()));
474473
}
475474
"CFG_MUSL_ROOT" if value.len() > 0 => {
476475
self.musl_root = Some(parse_configure_path(value));

0 commit comments

Comments
 (0)