Skip to content

Commit

Permalink
Auto merge of #97409 - GuillaumeGomez:rollup-808v9ge, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

 - #97317 (Allow to click on setting text)
 - #97375 (Simplify implementation of `-Z gcc-ld`)
 - #97394 (Add more eslint rules)
 - #97407 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed May 25, 2022
2 parents 4cbaac6 + f74e61e commit 464ec64
Show file tree
Hide file tree
Showing 23 changed files with 154 additions and 173 deletions.
7 changes: 1 addition & 6 deletions compiler/rustc_codegen_ssa/src/back/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ impl Command {
}
Program::Lld(ref p, flavor) => {
let mut c = process::Command::new(p);
c.arg("-flavor").arg(match flavor {
LldFlavor::Wasm => "wasm",
LldFlavor::Ld => "gnu",
LldFlavor::Link => "link",
LldFlavor::Ld64 => "darwin",
});
c.arg("-flavor").arg(flavor.as_str());
if let LldFlavor::Wasm = flavor {
// LLVM expects host-specific formatting for @file
// arguments, but we always generate posix formatted files
Expand Down
45 changes: 14 additions & 31 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2698,37 +2698,20 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
if let LinkerFlavor::Gcc = flavor {
match ld_impl {
LdImpl::Lld => {
if sess.target.lld_flavor == LldFlavor::Ld64 {
let tools_path = sess.get_tools_search_paths(false);
let ld64_exe = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.map(|p| {
p.join(if sess.host.is_like_windows { "ld64.exe" } else { "ld64" })
})
.find(|p| p.exists())
.unwrap_or_else(|| sess.fatal("rust-lld (as ld64) not found"));
cmd.cmd().arg({
let mut arg = OsString::from("-fuse-ld=");
arg.push(ld64_exe);
arg
});
} else {
let tools_path = sess.get_tools_search_paths(false);
let lld_path = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.find(|p| {
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" })
.exists()
})
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
cmd.cmd().arg({
let mut arg = OsString::from("-B");
arg.push(lld_path);
arg
});
}
let tools_path = sess.get_tools_search_paths(false);
let gcc_ld_dir = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.find(|p| {
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
})
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
cmd.arg({
let mut arg = OsString::from("-B");
arg.push(gcc_ld_dir);
arg
});
cmd.arg(format!("-Wl,-rustc-lld-flavor={}", sess.target.lld_flavor.as_str()));
}
}
} else {
Expand Down
17 changes: 10 additions & 7 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ pub enum LldFlavor {
}

impl LldFlavor {
pub fn as_str(&self) -> &'static str {
match self {
LldFlavor::Wasm => "wasm",
LldFlavor::Ld64 => "darwin",
LldFlavor::Ld => "gnu",
LldFlavor::Link => "link",
}
}

fn from_str(s: &str) -> Option<Self> {
Some(match s {
"darwin" => LldFlavor::Ld64,
Expand All @@ -121,13 +130,7 @@ impl LldFlavor {

impl ToJson for LldFlavor {
fn to_json(&self) -> Json {
match *self {
LldFlavor::Ld64 => "darwin",
LldFlavor::Ld => "gnu",
LldFlavor::Link => "link",
LldFlavor::Wasm => "wasm",
}
.to_json()
self.as_str().to_json()
}
}

Expand Down
13 changes: 5 additions & 8 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,14 +1164,11 @@ impl Step for Assemble {
// for `-Z gcc-ld=lld`
let gcc_ld_dir = libdir_bin.join("gcc-ld");
t!(fs::create_dir(&gcc_ld_dir));
for flavor in ["ld", "ld64"] {
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
compiler: build_compiler,
target: target_compiler.host,
flavor_feature: flavor,
});
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(flavor, target_compiler.host)));
}
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
compiler: build_compiler,
target: target_compiler.host,
});
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe("ld", target_compiler.host)));
}

if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
Expand Down
7 changes: 2 additions & 5 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,8 @@ impl Step for Rustc {
let gcc_lld_src_dir = src_dir.join("gcc-ld");
let gcc_lld_dst_dir = dst_dir.join("gcc-ld");
t!(fs::create_dir(&gcc_lld_dst_dir));
for flavor in ["ld", "ld64"] {
let exe_name = exe(flavor, compiler.host);
builder
.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
}
let exe_name = exe("ld", compiler.host);
builder.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
}

// Man pages
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ impl Step for Cargo {
pub struct LldWrapper {
pub compiler: Compiler,
pub target: TargetSelection,
pub flavor_feature: &'static str,
}

impl Step for LldWrapper {
Expand All @@ -676,7 +675,7 @@ impl Step for LldWrapper {
path: "src/tools/lld-wrapper",
is_optional_tool: false,
source_type: SourceType::InTree,
extra_features: vec![self.flavor_feature.to_owned()],
extra_features: Vec::new(),
})
.expect("expected to build -- essential tool");

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.3
0.9.5
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 123 files
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
7 changes: 7 additions & 0 deletions src/librustdoc/html/static/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ module.exports = {
{ "beforeColon": false, "afterColon": true, "mode": "strict" }
],
"func-call-spacing": ["error", "never"],
"space-infix-ops": "error",
"space-before-function-paren": ["error", "never"],
"space-before-blocks": "error",
"comma-dangle": ["error", "always-multiline"],
"comma-style": ["error", "last"],
"max-len": ["error", { "code": 100, "tabWidth": 4 }],
"eol-last": ["error", "always"],
}
};
24 changes: 0 additions & 24 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1415,30 +1415,6 @@ pre.rust {
#settings-menu.rotate > a img {
animation: rotating 2s linear infinite;
}
#settings-menu #settings {
position: absolute;
right: 0;
z-index: 1;
display: block;
margin-top: 7px;
border-radius: 3px;
border: 1px solid;
}
#settings-menu #settings .setting-line {
margin: 0.6em;
}
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
#settings-menu #settings::before {
content: '';
position: absolute;
right: 11px;
border: solid;
border-width: 1px 1px 0 0;
display: inline-block;
padding: 4px;
transform: rotate(-45deg);
top: -5px;
}

#help-button {
font-family: "Fira Sans", Arial, sans-serif;
Expand Down
40 changes: 34 additions & 6 deletions src/librustdoc/html/static/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@
.toggle {
position: relative;
display: inline-block;
width: 45px;
width: 100%;
height: 27px;
margin-right: 20px;
display: flex;
align-items: center;
cursor: pointer;
}

.toggle input {
Expand All @@ -57,12 +60,12 @@
}

.slider {
position: absolute;
position: relative;
width: 45px;
display: block;
height: 28px;
margin-right: 20px;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .3s;
}
Expand Down Expand Up @@ -95,3 +98,28 @@ input:checked + .slider:before {
width: 100%;
display: block;
}

div#settings {
position: absolute;
right: 0;
z-index: 1;
display: block;
margin-top: 7px;
border-radius: 3px;
border: 1px solid;
}
#settings .setting-line {
margin: 1.2em 0.6em;
}
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
div#settings::before {
content: '';
position: absolute;
right: 11px;
border: solid;
border-width: 1px 1px 0 0;
display: inline-block;
padding: 4px;
transform: rotate(-45deg);
top: -5px;
}
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function showMain() {
removeClass(document.getElementById(MAIN_ID), "hidden");
}

(function () {
(function() {
window.rootPath = getVar("root-path");
window.currentCrate = getVar("current-crate");
window.searchJS = resourcePath("search", ".js");
Expand Down Expand Up @@ -929,7 +929,7 @@ function loadCss(cssFileName) {
searchState.setup();
}());

(function () {
(function() {
let reset_button_timeout = null;

window.copy_path = but => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/scrape-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

(function () {
(function() {
// Number of lines shown when code viewer is not expanded
const MAX_LINES = 10;

Expand Down
13 changes: 6 additions & 7 deletions src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

"use strict";

(function () {
(function() {
const isSettingsPage = window.location.pathname.endsWith("/settings.html");

function changeSetting(settingName, value) {
Expand Down Expand Up @@ -130,12 +130,11 @@
} else {
// This is a toggle.
const checked = setting["default"] === true ? " checked" : "";
output += `
<label class="toggle">
<input type="checkbox" id="${js_data_name}"${checked}>
<span class="slider"></span>
</label>
<div>${setting_name}</div>`;
output += `<label class="toggle">\
<input type="checkbox" id="${js_data_name}"${checked}>\
<span class="slider"></span>\
<span class="label">${setting_name}</span>\
</label>`;
}
output += "</div>";
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function highlightSourceLines(match) {
}
}

const handleSourceHighlight = (function () {
const handleSourceHighlight = (function() {
let prev_line_id = 0;

const set_fragment = name => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const darkThemes = ["dark", "ayu"];
window.currentTheme = document.getElementById("themeStyle");
window.mainTheme = document.getElementById("mainThemeStyle");

const settingsDataset = (function () {
const settingsDataset = (function() {
const settingsElement = document.getElementById("default-settings");
if (settingsElement === null) {
return null;
Expand Down Expand Up @@ -163,7 +163,7 @@ function useSystemTheme(value) {
}
}

const updateSystemTheme = (function () {
const updateSystemTheme = (function() {
if (!window.matchMedia) {
// fallback to the CSS computed value
return () => {
Expand Down
10 changes: 8 additions & 2 deletions src/test/rustdoc-gui/settings.goml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ wait-for: "#settings"

// We check that the "Use system theme" is disabled.
assert-property: ("#use-system-theme", {"checked": "false"})
assert: "//*[@class='setting-line']/*[text()='Use system theme']"
assert: "//*[@class='setting-line']//span[text()='Use system theme']"
// Meaning that only the "theme" menu is showing up.
assert: ".setting-line:not(.hidden) #theme"
assert: ".setting-line.hidden #preferred-dark-theme"
Expand All @@ -55,7 +55,13 @@ assert: ".setting-line.hidden #theme"
assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")

// We now check that clicking on the "sliders"' text is like clicking on the slider.
// To test it, we use the "Disable keyboard shortcuts".
local-storage: {"rustdoc-disable-shortcuts": "false"}
click: ".setting-line:last-child .toggle .label"
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}

// Now we go to the settings page to check that the CSS is loaded as expected.
goto: file://|DOC_PATH|/settings.html
wait-for: "#settings"
assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"})
assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"})
6 changes: 0 additions & 6 deletions src/tools/lld-wrapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ name = "lld-wrapper"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]

[features]
ld = []
ld64 = []
Loading

0 comments on commit 464ec64

Please sign in to comment.