Skip to content

Commit 59e70f2

Browse files
committed
Auto merge of #57405 - pietroalbini:rollup, r=pietroalbini
Rollup of 6 pull requests Successful merges: - #57290 (remove outdated comment) - #57308 (Make CompileController thread-safe) - #57358 (use utf-8 throughout htmldocck) - #57369 (Provide the option to use libc++ even on all platforms) - #57375 (Add duration constants) - #57403 (Make extern ref HTTPS) Failed merges: - #57370 (Support passing cflags/cxxflags/ldflags to LLVM build) r? @ghost
2 parents 21ac19d + 6031f13 commit 59e70f2

File tree

14 files changed

+72
-26
lines changed

14 files changed

+72
-26
lines changed

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ And if someone takes issue with something you said or did, resist the urge to be
3535

3636
The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.
3737

38-
*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*
38+
*Adapted from the [Node.js Policy on Trolling](https://blog.izs.me/2012/08/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*
3939

4040
[mod_team]: https://www.rust-lang.org/team.html#Moderation-team

config.toml.example

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
# with clang-cl, so this is special in that it only compiles LLVM with clang-cl
9191
#clang-cl = '/path/to/clang-cl.exe'
9292

93+
# Use libc++ when building LLVM instead of libstdc++. This is the default on
94+
# platforms already use libc++ as the default C++ library, but this option
95+
# allows you to use libc++ even on platforms when it's not. You need to ensure
96+
# that your host compiler ships with libc++.
97+
#use-libcxx = true
98+
9399
# =============================================================================
94100
# General build configuration options
95101
# =============================================================================

src/bootstrap/compile.rs

+3
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,9 @@ pub fn build_codegen_backend(builder: &Builder,
723723
{
724724
cargo.env("LLVM_LINK_SHARED", "1");
725725
}
726+
if builder.config.llvm_use_libcxx {
727+
cargo.env("LLVM_USE_LIBCXX", "1");
728+
}
726729
}
727730
_ => panic!("unknown backend: {}", backend),
728731
}

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ pub struct Config {
8282
pub lldb_enabled: bool,
8383
pub llvm_tools_enabled: bool,
8484

85+
pub llvm_use_libcxx: bool,
86+
8587
// rust codegen options
8688
pub rust_optimize: bool,
8789
pub rust_codegen_units: Option<u32>,
@@ -252,6 +254,7 @@ struct Llvm {
252254
link_shared: Option<bool>,
253255
version_suffix: Option<String>,
254256
clang_cl: Option<String>,
257+
use_libcxx: Option<bool>,
255258
}
256259

257260
#[derive(Deserialize, Default, Clone)]
@@ -513,6 +516,7 @@ impl Config {
513516
config.llvm_link_jobs = llvm.link_jobs;
514517
config.llvm_version_suffix = llvm.version_suffix.clone();
515518
config.llvm_clang_cl = llvm.clang_cl.clone();
519+
set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
516520
}
517521

518522
if let Some(ref rust) = toml.rust {

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def v(*args):
6262
o("lld", "rust.lld", "build lld")
6363
o("lldb", "rust.lldb", "build lldb")
6464
o("missing-tools", "dist.missing-tools", "allow failures when building tools")
65+
o("use-libcxx", "llvm.use_libcxx", "build LLVM with libc++")
6566

6667
# Optimization and debugging options. These may be overridden by the release
6768
# channel, etc.

src/etc/htmldocck.py

+28-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
14
r"""
25
htmldocck.py is a custom checker script for Rustdoc HTML outputs.
36
@@ -98,7 +101,10 @@
98101
99102
"""
100103

101-
from __future__ import print_function
104+
from __future__ import absolute_import, print_function, unicode_literals
105+
106+
import codecs
107+
import io
102108
import sys
103109
import os.path
104110
import re
@@ -110,14 +116,10 @@
110116
from HTMLParser import HTMLParser
111117
from xml.etree import cElementTree as ET
112118

113-
# &larrb;/&rarrb; are not in HTML 4 but are in HTML 5
114119
try:
115-
from html.entities import entitydefs
120+
from html.entities import name2codepoint
116121
except ImportError:
117-
from htmlentitydefs import entitydefs
118-
entitydefs['larrb'] = u'\u21e4'
119-
entitydefs['rarrb'] = u'\u21e5'
120-
entitydefs['nbsp'] = ' '
122+
from htmlentitydefs import name2codepoint
121123

122124
# "void elements" (no closing tag) from the HTML Standard section 12.1.2
123125
VOID_ELEMENTS = set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
@@ -157,11 +159,11 @@ def handle_data(self, data):
157159
self.__builder.data(data)
158160

159161
def handle_entityref(self, name):
160-
self.__builder.data(entitydefs[name])
162+
self.__builder.data(unichr(name2codepoint[name]))
161163

162164
def handle_charref(self, name):
163165
code = int(name[1:], 16) if name.startswith(('x', 'X')) else int(name, 10)
164-
self.__builder.data(unichr(code).encode('utf-8'))
166+
self.__builder.data(unichr(code))
165167

166168
def close(self):
167169
HTMLParser.close(self)
@@ -210,11 +212,11 @@ def concat_multi_lines(f):
210212
(?<=(?<!\S)@)(?P<negated>!?)
211213
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
212214
(?P<args>.*)$
213-
''', re.X)
215+
''', re.X | re.UNICODE)
214216

215217

216218
def get_commands(template):
217-
with open(template, 'rU') as f:
219+
with io.open(template, encoding='utf-8') as f:
218220
for lineno, line in concat_multi_lines(f):
219221
m = LINE_PATTERN.search(line)
220222
if not m:
@@ -226,7 +228,10 @@ def get_commands(template):
226228
if args and not args[:1].isspace():
227229
print_err(lineno, line, 'Invalid template syntax')
228230
continue
229-
args = shlex.split(args)
231+
try:
232+
args = shlex.split(args)
233+
except UnicodeEncodeError:
234+
args = [arg.decode('utf-8') for arg in shlex.split(args.encode('utf-8'))]
230235
yield Command(negated=negated, cmd=cmd, args=args, lineno=lineno+1, context=line)
231236

232237

@@ -280,7 +285,7 @@ def get_file(self, path):
280285
if not(os.path.exists(abspath) and os.path.isfile(abspath)):
281286
raise FailedCheck('File does not exist {!r}'.format(path))
282287

283-
with open(abspath) as f:
288+
with io.open(abspath, encoding='utf-8') as f:
284289
data = f.read()
285290
self.files[path] = data
286291
return data
@@ -294,9 +299,9 @@ def get_tree(self, path):
294299
if not(os.path.exists(abspath) and os.path.isfile(abspath)):
295300
raise FailedCheck('File does not exist {!r}'.format(path))
296301

297-
with open(abspath) as f:
302+
with io.open(abspath, encoding='utf-8') as f:
298303
try:
299-
tree = ET.parse(f, CustomHTMLParser())
304+
tree = ET.fromstringlist(f.readlines(), CustomHTMLParser())
300305
except Exception as e:
301306
raise RuntimeError('Cannot parse an HTML file {!r}: {}'.format(path, e))
302307
self.trees[path] = tree
@@ -313,7 +318,7 @@ def check_string(data, pat, regexp):
313318
if not pat:
314319
return True # special case a presence testing
315320
elif regexp:
316-
return re.search(pat, data) is not None
321+
return re.search(pat, data, flags=re.UNICODE) is not None
317322
else:
318323
data = ' '.join(data.split())
319324
pat = ' '.join(pat.split())
@@ -350,7 +355,7 @@ def check_tree_text(tree, path, pat, regexp):
350355
break
351356
except Exception as e:
352357
print('Failed to get path "{}"'.format(path))
353-
raise e
358+
raise
354359
return ret
355360

356361

@@ -359,7 +364,12 @@ def get_tree_count(tree, path):
359364
return len(tree.findall(path))
360365

361366
def stderr(*args):
362-
print(*args, file=sys.stderr)
367+
if sys.version_info.major < 3:
368+
file = codecs.getwriter('utf-8')(sys.stderr)
369+
else:
370+
file = sys.stderr
371+
372+
print(*args, file=file)
363373

364374
def print_err(lineno, context, err, message=None):
365375
global ERR_COUNT

src/libcore/time.rs

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ const MILLIS_PER_SEC: u64 = 1_000;
2323
const MICROS_PER_SEC: u64 = 1_000_000;
2424
const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;
2525

26+
/// The duration of one second.
27+
#[unstable(feature = "duration_constants", issue = "57391")]
28+
pub const SECOND: Duration = Duration::from_secs(1);
29+
30+
/// The duration of one millisecond.
31+
#[unstable(feature = "duration_constants", issue = "57391")]
32+
pub const MILLISECOND: Duration = Duration::from_millis(1);
33+
34+
/// The duration of one microsecond.
35+
#[unstable(feature = "duration_constants", issue = "57391")]
36+
pub const MICROSECOND: Duration = Duration::from_micros(1);
37+
38+
/// The duration of one nanosecond.
39+
#[unstable(feature = "duration_constants", issue = "57391")]
40+
pub const NANOSECOND: Duration = Duration::from_nanos(1);
41+
2642
/// A `Duration` type to represent a span of time, typically used for system
2743
/// timeouts.
2844
///

src/librustc/ty/context.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2930,9 +2930,6 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
29302930
}
29312931

29322932
pub fn provide(providers: &mut ty::query::Providers<'_>) {
2933-
// FIXME(#44234): almost all of these queries have no sub-queries and
2934-
// therefore no actual inputs, they're just reading tables calculated in
2935-
// resolve! Does this work? Unsure! That's what the issue is about.
29362933
providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id).cloned();
29372934
providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).cloned();
29382935
providers.crate_name = |tcx, id| {

src/librustc_data_structures/sync.rs

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ cfg_if! {
323323
}
324324

325325
pub fn assert_sync<T: ?Sized + Sync>() {}
326+
pub fn assert_send<T: ?Sized + Send>() {}
326327
pub fn assert_send_val<T: ?Sized + Send>(_t: &T) {}
327328
pub fn assert_send_sync_val<T: ?Sized + Sync + Send>(_t: &T) {}
328329

src/librustc_driver/driver.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,15 @@ pub struct CompileController<'a> {
402402

403403
/// Allows overriding default rustc query providers,
404404
/// after `default_provide` has installed them.
405-
pub provide: Box<dyn Fn(&mut ty::query::Providers) + 'a>,
405+
pub provide: Box<dyn Fn(&mut ty::query::Providers) + 'a + sync::Send>,
406406
/// Same as `provide`, but only for non-local crates,
407407
/// applied after `default_provide_extern`.
408-
pub provide_extern: Box<dyn Fn(&mut ty::query::Providers) + 'a>,
408+
pub provide_extern: Box<dyn Fn(&mut ty::query::Providers) + 'a + sync::Send>,
409409
}
410410

411411
impl<'a> CompileController<'a> {
412412
pub fn basic() -> CompileController<'a> {
413+
sync::assert_send::<Self>();
413414
CompileController {
414415
after_parse: PhaseController::basic(),
415416
after_expand: PhaseController::basic(),
@@ -499,7 +500,7 @@ pub struct PhaseController<'a> {
499500
// If true then the compiler will try to run the callback even if the phase
500501
// ends with an error. Note that this is not always possible.
501502
pub run_callback_on_error: bool,
502-
pub callback: Box<dyn Fn(&mut CompileState) + 'a>,
503+
pub callback: Box<dyn Fn(&mut CompileState) + 'a + sync::Send>,
503504
}
504505

505506
impl<'a> PhaseController<'a> {

src/librustc_llvm/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ fn main() {
236236
}
237237

238238
let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP");
239+
let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX");
239240

240241
let stdcppname = if target.contains("openbsd") {
241242
// llvm-config on OpenBSD doesn't mention stdlib=libc++
@@ -245,6 +246,8 @@ fn main() {
245246
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
246247
// NetBSD uses a separate library when relocation is required
247248
"stdc++_pic"
249+
} else if llvm_use_libcxx.is_some() {
250+
"c++"
248251
} else {
249252
"stdc++"
250253
};

src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248
#![feature(const_cstr_unchecked)]
249249
#![feature(core_intrinsics)]
250250
#![feature(dropck_eyepatch)]
251+
#![feature(duration_constants)]
251252
#![feature(exact_size_is_empty)]
252253
#![feature(external_doc)]
253254
#![feature(fixed_size_array)]

src/libstd/time.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ use sys_common::FromInner;
2121
#[stable(feature = "time", since = "1.3.0")]
2222
pub use core::time::Duration;
2323

24+
#[unstable(feature = "duration_constants", issue = "57391")]
25+
pub use core::time::{SECOND, MILLISECOND, MICROSECOND, NANOSECOND};
26+
2427
/// A measurement of a monotonically nondecreasing clock.
2528
/// Opaque and useful only with `Duration`.
2629
///

src/test/rustdoc/issue-32374.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// 'Deprecated since 1.0.0: text'
1111
// @has - '<code>test</code>&nbsp;<a href="http://issue_url/32374">#32374</a>'
1212
// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \
13-
// '🔬 This is a nightly-only experimental API. \(test #32374\)$'
13+
// '🔬 This is a nightly-only experimental API. \(test\s#32374\)$'
1414
/// Docs
1515
#[rustc_deprecated(since = "1.0.0", reason = "text")]
1616
#[unstable(feature = "test", issue = "32374")]

0 commit comments

Comments
 (0)