Skip to content

No libc msvc #123938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ jobs:
- name: mingw-check-tidy
os: ubuntu-20.04-4core-16gb
env: {}
- name: x86_64-gnu-llvm-17
- name: x86_64-msvc
env:
ENABLE_GCC_CODEGEN: "1"
os: ubuntu-20.04-16core-64gb
- name: x86_64-gnu-tools
os: ubuntu-20.04-16core-64gb
env: {}
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-profiler"
SCRIPT: make ci-msvc
os: windows-2019-8core-32gb
defaults:
run:
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
Expand Down
8 changes: 6 additions & 2 deletions library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ impl () {}
/// ## 4. Get it from C.
///
/// ```
/// # #![feature(rustc_private)]
/// # mod libc {
/// # pub unsafe fn malloc(_size: usize) -> *mut u8 { core::ptr::NonNull::dangling().as_ptr() }
/// # pub unsafe fn free(mem: *mut core::ffi::c_void) {}
/// # }
/// # #[cfg(any())]
/// #[allow(unused_extern_crates)]
/// extern crate libc;
///
Expand All @@ -548,7 +552,7 @@ impl () {}
/// if my_num.is_null() {
/// panic!("failed to allocate memory");
/// }
/// libc::free(my_num as *mut libc::c_void);
/// libc::free(my_num as *mut core::ffi::c_void);
/// }
/// ```
///
Expand Down
3 changes: 0 additions & 3 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ addr2line = { version = "0.21.0", optional = true, default-features = false }
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
libc = { version = "0.2.153", default-features = false, features = ['rustc-dep-of-std'], public = true }

[target.'cfg(all(windows, target_env = "msvc"))'.dependencies]
libc = { version = "0.2.153", default-features = false }

[target.'cfg(all(not(target_os = "aix"), not(all(windows, target_env = "msvc", not(target_vendor = "uwp")))))'.dependencies]
object = { version = "0.32.0", default-features = false, optional = true, features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] }

Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ extern crate alloc as alloc_crate;
// so include it here even if it's unused.
#[doc(masked)]
#[allow(unused_extern_crates)]
#[cfg(not(all(windows, target_env = "msvc")))]
extern crate libc;

// We always need an unwinder currently for backtraces
Expand Down
1 change: 1 addition & 0 deletions library/std/src/os/raw/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(all(windows, target_env = "msvc")))]
use crate::any::TypeId;

macro_rules! ok {
Expand Down
2 changes: 1 addition & 1 deletion library/stdarch
10 changes: 4 additions & 6 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,11 @@ jobs:
- name: mingw-check-tidy
<<: *job-linux-4c

- name: x86_64-gnu-llvm-17
- name: x86_64-msvc
env:
ENABLE_GCC_CODEGEN: "1"
<<: *job-linux-16c

- name: x86_64-gnu-tools
<<: *job-linux-16c
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler
SCRIPT: make ci-msvc
<<: *job-windows-8c

auto:
<<: *base-ci-job
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-fulldeps/regions-mock-tcx.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
//@ ignore-msvc

#![allow(dead_code)]
#![allow(unused_imports)]
Expand All @@ -9,10 +10,9 @@
// - Multiple lifetime parameters
// - Arenas

#![feature(rustc_private, libc)]
#![feature(rustc_private)]

extern crate rustc_arena;
extern crate libc;

// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta
// files.
Expand Down
6 changes: 1 addition & 5 deletions tests/ui/abi/c-stack-returning-int64.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
//@ run-pass
//@ ignore-sgx no libc

#![feature(rustc_private)]

extern crate libc;

use std::ffi::CString;

mod mlibc {
use libc::{c_char, c_long, c_longlong};
use std::ffi::{c_char, c_long, c_longlong};

extern "C" {
pub fn atol(x: *const c_char) -> c_long;
Expand Down
10 changes: 4 additions & 6 deletions tests/ui/abi/statics/static-mut-foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
// statics cannot. This ensures that there's some form of error if this is
// attempted.

#![feature(rustc_private)]

extern crate libc;
use std::ffi::c_int;

#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
static mut rust_dbg_static_mut: libc::c_int;
static mut rust_dbg_static_mut: c_int;
pub fn rust_dbg_static_mut_check_four();
}

unsafe fn static_bound(_: &'static libc::c_int) {}
unsafe fn static_bound(_: &'static c_int) {}

fn static_bound_set(a: &'static mut libc::c_int) {
fn static_bound_set(a: &'static mut c_int) {
*a = 3;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/abi/statics/static-mut-foreign.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-foreign.rs:33:18
--> $DIR/static-mut-foreign.rs:31:18
|
LL | static_bound(&rust_dbg_static_mut);
| ^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
Expand All @@ -14,7 +14,7 @@ LL | static_bound(addr_of!(rust_dbg_static_mut));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

warning: creating a mutable reference to mutable static is discouraged
--> $DIR/static-mut-foreign.rs:35:22
--> $DIR/static-mut-foreign.rs:33:22
|
LL | static_bound_set(&mut rust_dbg_static_mut);
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/array-slice-vec/vec-macro-no-std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

extern crate std as other;

extern crate libc;

#[macro_use]
extern crate alloc;

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/auxiliary/check_static_recursion_foreign_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![crate_name = "check_static_recursion_foreign_helper"]
#![crate_type = "lib"]

extern crate libc;
use std::ffi::c_int;

#[no_mangle]
pub static test_static: libc::c_int = 0;
pub static test_static: c_int = 0;
5 changes: 1 addition & 4 deletions tests/ui/check-static-recursion-foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

//@ pretty-expanded FIXME #23616

#![feature(rustc_private)]

extern crate check_static_recursion_foreign_helper;
extern crate libc;

use libc::c_int;
use std::ffi::c_int;

extern "C" {
static test_static: c_int;
Expand Down
4 changes: 1 addition & 3 deletions tests/ui/extern/extern-const.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

//@ run-rustfix
//@ compile-flags: -g
#![feature(rustc_private)]
extern crate libc;

#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
static rust_dbg_static_mut: libc::c_int; //~ ERROR extern items cannot be `const`
static rust_dbg_static_mut: i32; //~ ERROR extern items cannot be `const`
}

fn main() {
Expand Down
4 changes: 1 addition & 3 deletions tests/ui/extern/extern-const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

//@ run-rustfix
//@ compile-flags: -g
#![feature(rustc_private)]
extern crate libc;

#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
const rust_dbg_static_mut: libc::c_int; //~ ERROR extern items cannot be `const`
const rust_dbg_static_mut: i32; //~ ERROR extern items cannot be `const`
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/extern/extern-const.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: extern items cannot be `const`
--> $DIR/extern-const.rs:14:11
--> $DIR/extern-const.rs:12:11
|
LL | const rust_dbg_static_mut: libc::c_int;
LL | const rust_dbg_static_mut: i32;
| ------^^^^^^^^^^^^^^^^^^^
| |
| help: try using a static value: `static`
Expand Down
1 change: 0 additions & 1 deletion tests/ui/internal-lints/existing_doc_keyword.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ compile-flags: -Z unstable-options

#![feature(rustc_private)]
#![feature(rustdoc_internals)]

#![crate_type = "lib"]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/internal-lints/existing_doc_keyword.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]`
--> $DIR/existing_doc_keyword.rs:10:1
--> $DIR/existing_doc_keyword.rs:9:1
|
LL | #[doc(keyword = "tadam")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: only existing keywords are allowed in core/std
note: the lint level is defined here
--> $DIR/existing_doc_keyword.rs:8:9
--> $DIR/existing_doc_keyword.rs:7:9
|
LL | #![deny(rustc::existing_doc_keyword)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 0 additions & 3 deletions tests/ui/issues/issue-13259-windows-tcb-trash.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//@ run-pass
#![feature(rustc_private)]

extern crate libc;

#[cfg(windows)]
mod imp {
Expand Down
4 changes: 0 additions & 4 deletions tests/ui/issues/issue-22034.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#![feature(rustc_private)]

extern crate libc;

fn main() {
let ptr: *mut () = core::ptr::null_mut();
let _: &mut dyn Fn() = unsafe {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-22034.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: expected a `Fn()` closure, found `()`
--> $DIR/issue-22034.rs:8:16
--> $DIR/issue-22034.rs:4:16
|
LL | &mut *(ptr as *mut dyn Fn())
| ^^^ expected an `Fn()` closure, found `()`
Expand Down
8 changes: 2 additions & 6 deletions tests/ui/issues/issue-2214.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//@ run-pass
//@ ignore-wasm32 wasi-libc does not have lgamma
//@ ignore-sgx no libc
#![feature(rustc_private)]

extern crate libc;

use libc::{c_double, c_int};
use std::ffi::{c_double, c_int};
use std::mem;

fn to_c_int(v: &mut isize) -> &mut c_int {
Expand All @@ -19,8 +16,7 @@ fn lgamma(n: c_double, value: &mut isize) -> c_double {
}

mod m {
use libc::{c_double, c_int};

use std::ffi::{c_double, c_int};
extern "C" {
#[cfg(all(unix, not(target_os = "vxworks")))]
#[link_name="lgamma_r"]
Expand Down
4 changes: 1 addition & 3 deletions tests/ui/issues/issue-3656.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
// the alignment of elements into account.

//@ pretty-expanded FIXME #23616
#![feature(rustc_private)]

extern crate libc;
use libc::{c_uint, c_void};
use std::ffi::{c_uint, c_void};

pub struct KEYGEN {
hash_algorithm: [c_uint; 2],
Expand Down
9 changes: 3 additions & 6 deletions tests/ui/lint/lint-ctypes-fn.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#![feature(rustc_private)]

#![allow(private_interfaces)]
#![deny(improper_ctypes_definitions)]

extern crate libc;

use std::default::Default;
use std::marker::PhantomData;
use std::ffi::{c_int, c_uint};

trait Trait {}

Expand Down Expand Up @@ -165,10 +162,10 @@ pub extern "C" fn good17(p: TransparentCustomZst) { }
pub extern "C" fn good18(_: &String) { }

#[cfg(not(target_arch = "wasm32"))]
pub extern "C" fn good1(size: *const libc::c_int) { }
pub extern "C" fn good1(size: *const c_int) { }

#[cfg(not(target_arch = "wasm32"))]
pub extern "C" fn good2(size: *const libc::c_uint) { }
pub extern "C" fn good2(size: *const c_uint) { }

pub extern "C" fn unused_generic1<T>(size: *const Foo) { }

Expand Down
Loading
Loading