From 1f8935e7a2ddacca97f615c7b1bda4db9fce7769 Mon Sep 17 00:00:00 2001 From: shourya5 Date: Wed, 18 Jan 2023 22:39:50 -0600 Subject: [PATCH 1/4] appends --set arguments to config.toml --- src/bootstrap/configure.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 0af329e7007ac..4682d1cb1c5d4 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -458,17 +458,25 @@ def configure_section(lines, config): else: raise RuntimeError("failed to find config line for {}".format(key)) - +cli_args = {} for section_key in config: + section_config = config[section_key] + #key is not in toml file,added via --set from command line if section_key not in sections: - raise RuntimeError("config key {} not in sections".format(section_key)) + #key is not in toml file,added via --set from command line + cli_args[section_key] = section_config + continue + #raise RuntimeError("config key {} not in sections".format(section_key)) if section_key == 'target': for target in section_config: configure_section(targets[target], section_config[target]) + else: + val = sections[section_key] configure_section(sections[section_key], section_config) + #sections.pop(section_key) # Now that we've built up our `config.toml`, write it all out in the same # order that we read it in. @@ -483,6 +491,8 @@ def configure_section(lines, config): else: for line in sections[section]: f.write(line + "\n") + for key in cli_args: + f.write(key + ' = ' + cli_args[key] ) with bootstrap.output('Makefile') as f: contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in') From 65cb513a3e77e6014048bd9bf9150781893cff4a Mon Sep 17 00:00:00 2001 From: shourya5 Date: Wed, 18 Jan 2023 22:41:47 -0600 Subject: [PATCH 2/4] appends --set arguments to config.toml --- src/bootstrap/configure.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 4682d1cb1c5d4..2684708182f4b 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -462,21 +462,18 @@ def configure_section(lines, config): for section_key in config: section_config = config[section_key] - #key is not in toml file,added via --set from command line + if section_key not in sections: #key is not in toml file,added via --set from command line cli_args[section_key] = section_config continue - #raise RuntimeError("config key {} not in sections".format(section_key)) - + if section_key == 'target': for target in section_config: configure_section(targets[target], section_config[target]) - else: - val = sections[section_key] configure_section(sections[section_key], section_config) - #sections.pop(section_key) + # Now that we've built up our `config.toml`, write it all out in the same # order that we read it in. @@ -491,8 +488,8 @@ def configure_section(lines, config): else: for line in sections[section]: f.write(line + "\n") - for key in cli_args: - f.write(key + ' = ' + cli_args[key] ) + for arg in cli_args: + f.write(arg + ' = ' + cli_args[arg] ) with bootstrap.output('Makefile') as f: contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in') From ddb8389b6267ef278842baa776623670975c59cc Mon Sep 17 00:00:00 2001 From: shourya5 Date: Wed, 18 Jan 2023 23:03:43 -0600 Subject: [PATCH 3/4] Updated README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0eb7c4b266a9f..6ea60ae84e463 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,11 @@ See [the rustc-dev-guide for more info][sysllvm]. list of options in `config.toml.example`. ```sh - printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml + ./configure --set profile="user" + ./configure --set changelog-seen=2 ``` + If you plan to use `x.py install` to create an installation, it is recommended that you set the `prefix` value in the `[install]` section to a directory. From 3f5ff32789bcdf0e7bfb0ba83d0e46cc5c3e068f Mon Sep 17 00:00:00 2001 From: shourya5 Date: Sat, 21 Jan 2023 20:43:57 -0600 Subject: [PATCH 4/4] fix formatting issues --- src/bootstrap/configure.py | 101 ++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 35 deletions(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 2684708182f4b..4f56f557a0ca2 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -3,13 +3,13 @@ # ignore-tidy-linelength from __future__ import absolute_import, division, print_function +import bootstrap import sys import os rust_dir = os.path.dirname(os.path.abspath(__file__)) rust_dir = os.path.dirname(rust_dir) rust_dir = os.path.dirname(rust_dir) sys.path.append(os.path.join(rust_dir, "src", "bootstrap")) -import bootstrap class Option(object): @@ -31,28 +31,40 @@ def v(*args): options.append(Option(*args, value=True)) -o("debug", "rust.debug", "enables debugging environment; does not affect optimization of bootstrapped code") +o("debug", "rust.debug", + "enables debugging environment; does not affect optimization of bootstrapped code") o("docs", "build.docs", "build standard library documentation") o("compiler-docs", "build.compiler-docs", "build compiler documentation") o("optimize-tests", "rust.optimize-tests", "build tests with optimizations") -o("verbose-tests", "rust.verbose-tests", "enable verbose output when running tests") -o("ccache", "llvm.ccache", "invoke gcc/clang via ccache to reuse object files between builds") +o("verbose-tests", "rust.verbose-tests", + "enable verbose output when running tests") +o("ccache", "llvm.ccache", + "invoke gcc/clang via ccache to reuse object files between builds") o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds") o("local-rust", None, "use an installed rustc rather than downloading a snapshot") v("local-rust-root", None, "set prefix for local rust binary") -o("local-rebuild", "build.local-rebuild", "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version") -o("llvm-static-stdcpp", "llvm.static-libstdcpp", "statically link to libstdc++ for LLVM") -o("llvm-link-shared", "llvm.link-shared", "prefer shared linking to LLVM (llvm-config --link-shared)") +o("local-rebuild", "build.local-rebuild", + "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version") +o("llvm-static-stdcpp", "llvm.static-libstdcpp", + "statically link to libstdc++ for LLVM") +o("llvm-link-shared", "llvm.link-shared", + "prefer shared linking to LLVM (llvm-config --link-shared)") o("rpath", "rust.rpath", "build rpaths into rustc itself") -o("llvm-version-check", "llvm.version-check", "check if the LLVM version is supported, build anyway") +o("llvm-version-check", "llvm.version-check", + "check if the LLVM version is supported, build anyway") o("codegen-tests", "rust.codegen-tests", "run the tests/codegen tests") o("option-checking", None, "complain about unrecognized options in this configure script") -o("ninja", "llvm.ninja", "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)") +o("ninja", "llvm.ninja", + "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)") o("locked-deps", "build.locked-deps", "force Cargo.lock to be up to date") o("vendor", "build.vendor", "enable usage of vendored Rust crates") -o("sanitizers", "build.sanitizers", "build the sanitizer runtimes (asan, lsan, msan, tsan, hwasan)") -o("dist-src", "rust.dist-src", "when building tarballs enables building a source tarball") -o("cargo-native-static", "build.cargo-native-static", "static native libraries in cargo") +o("sanitizers", "build.sanitizers", + "build the sanitizer runtimes (asan, lsan, msan, tsan, hwasan)") +o("dist-src", "rust.dist-src", + "when building tarballs enables building a source tarball") +o("cargo-native-static", + "build.cargo-native-static", + "static native libraries in cargo") o("profiler", "build.profiler", "build the profiler runtime") o("full-tools", None, "enable all tools") o("lld", "rust.lld", "build lld") @@ -73,16 +85,27 @@ def v(*args): o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") -o("debug-assertions-std", "rust.debug-assertions-std", "build the standard library with debugging assertions") +o("debug-assertions-std", "rust.debug-assertions-std", + "build the standard library with debugging assertions") o("overflow-checks", "rust.overflow-checks", "build with overflow checks") -o("overflow-checks-std", "rust.overflow-checks-std", "build the standard library with overflow checks") -o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata") +o("overflow-checks-std", "rust.overflow-checks-std", + "build the standard library with overflow checks") +o("llvm-release-debuginfo", + "llvm.release-debuginfo", + "build LLVM with debugger metadata") v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code") -v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler") -v("debuginfo-level-std", "rust.debuginfo-level-std", "debuginfo level for the standard library") -v("debuginfo-level-tools", "rust.debuginfo-level-tools", "debuginfo level for the tools") -v("debuginfo-level-tests", "rust.debuginfo-level-tests", "debuginfo level for the test suites run with compiletest") -v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file") +v("debuginfo-level-rustc", + "rust.debuginfo-level-rustc", + "debuginfo level for the compiler") +v("debuginfo-level-std", "rust.debuginfo-level-std", + "debuginfo level for the standard library") +v("debuginfo-level-tools", + "rust.debuginfo-level-tools", + "debuginfo level for the tools") +v("debuginfo-level-tests", "rust.debuginfo-level-tests", + "debuginfo level for the test suites run with compiletest") +v("save-toolstates", "rust.save-toolstates", + "save build and test status of external tools into this file") v("prefix", "install.prefix", "set installation prefix") v("localstatedir", "install.localstatedir", "local state directory") @@ -106,7 +129,8 @@ def v(*args): "arm-linux-androideabi NDK standalone path") v("armv7-linux-androideabi-ndk", "target.armv7-linux-androideabi.android-ndk", "armv7-linux-androideabi NDK standalone path") -v("thumbv7neon-linux-androideabi-ndk", "target.thumbv7neon-linux-androideabi.android-ndk", +v("thumbv7neon-linux-androideabi-ndk", + "target.thumbv7neon-linux-androideabi.android-ndk", "thumbv7neon-linux-androideabi NDK standalone path") v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk", "aarch64-linux-android NDK standalone path") @@ -149,7 +173,8 @@ def v(*args): v("experimental-targets", "llvm.experimental-targets", "experimental LLVM targets to build") v("release-channel", "rust.channel", "the name of the release channel to build") -v("release-description", "rust.description", "optional descriptive string for version output") +v("release-description", "rust.description", + "optional descriptive string for version output") v("dist-compression-formats", None, "comma-separated list of compression formats to use") @@ -158,8 +183,10 @@ def v(*args): # Many of these are saved below during the "writing configuration" step # (others are conditionally saved). -o("manage-submodules", "build.submodules", "let the build manage the git submodules") -o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two (not recommended except for testing reproducible builds)") +o("manage-submodules", "build.submodules", + "let the build manage the git submodules") +o("full-bootstrap", "build.full-bootstrap", + "build three compilers instead of two (not recommended except for testing reproducible builds)") o("extended", "build.extended", "build an extended rust tool set") v("tools", None, "List of extended tools will be installed") @@ -189,9 +216,11 @@ def err(msg): # no one needs to know about these obscure options continue if option.value: - print('\t{:30} {}'.format('--{}=VAL'.format(option.name), option.desc)) + print('\t{:30} {}'.format( + '--{}=VAL'.format(option.name), option.desc)) else: - print('\t{:30} {}'.format('--enable-{}'.format(option.name), option.desc)) + print('\t{:30} {}'.format( + '--enable-{}'.format(option.name), option.desc)) print('') print('This configure script is a thin configuration shim over the true') print('configuration system, `config.toml`. You can explore the comments') @@ -386,7 +415,8 @@ def set(key, value): if cur_section.startswith('target'): cur_section = 'target' elif '.' in cur_section: - raise RuntimeError("don't know how to deal with section: {}".format(cur_section)) + raise RuntimeError( + "don't know how to deal with section: {}".format(cur_section)) sections[cur_section] = [line] section_order.append(cur_section) else: @@ -407,7 +437,9 @@ def set(key, value): targets[target] = sections['target'][:] # For `.` to be valid TOML, it needs to be quoted. But `bootstrap.py` doesn't use a proper TOML parser and fails to parse the target. # Avoid using quotes unless it's necessary. - targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", "'{}'".format(target) if "." in target else target) + targets[target][0] = targets[target][0].replace( + "x86_64-unknown-linux-gnu", + "'{}'".format(target) if "." in target else target) def is_number(value): @@ -456,24 +488,23 @@ def configure_section(lines, config): if key in ["infodir", "localstatedir"]: print("warning: {} will be ignored".format(key)) else: - raise RuntimeError("failed to find config line for {}".format(key)) + raise RuntimeError( + "failed to find config line for {}".format(key)) + cli_args = {} for section_key in config: - section_config = config[section_key] - if section_key not in sections: - #key is not in toml file,added via --set from command line + # key is not in toml file,added via --set from command line cli_args[section_key] = section_config continue - if section_key == 'target': for target in section_config: configure_section(targets[target], section_config[target]) else: configure_section(sections[section_key], section_config) - + # Now that we've built up our `config.toml`, write it all out in the same # order that we read it in. @@ -489,7 +520,7 @@ def configure_section(lines, config): for line in sections[section]: f.write(line + "\n") for arg in cli_args: - f.write(arg + ' = ' + cli_args[arg] ) + f.write(arg + ' = ' + cli_args[arg]) with bootstrap.output('Makefile') as f: contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in')