Skip to content
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

Move std::os::raw into core #52839

Closed
wants to merge 1 commit into from
Closed

Move std::os::raw into core #52839

wants to merge 1 commit into from

Conversation

joshlf
Copy link
Contributor

@joshlf joshlf commented Jul 30, 2018

Move the types in std::os::raw into core::os::raw, and re-export them from std::os::raw.

This allows these types to be used in a no-std environment without having to use libc, and also addresses rust-lang/rust-bindgen#1015.

There's a discussion about this on the internals forum here.

@rust-highfive
Copy link
Collaborator

r? @aidanhs

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 30, 2018
@Mark-Simulacrum
Copy link
Member

Core is intended to be platform-independent, so I don't think doing this is a good idea per current policies.

Cc @rust-lang/libs

@joshlf
Copy link
Contributor Author

joshlf commented Jul 30, 2018

Is this platform-dependent? There are no extern declarations, and none of the types are architecture-specific.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:start:tidy
tidy check
[00:03:48] * 553 error codes
[00:03:48] * highest error code: E0710
[00:03:49] tidy error: /checkout/src/libstd/os/mod.rs:13: mismatches to previous in: ["since"]
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs:24: platform-specific cfg: cfg(any(all(target_os = "linux", any(target_arch = "aarch64",
[00:03:49]                                        target_arch = "arm",
[00:03:49]                                        target_arch = "powerpc",
[00:03:49]                                        target_arch = "powerpc64",
[00:03:49]                                        target_arch = "s390x")),
[00:03:49]           all(target_os = "android", any(target_arch = "aarch64",
[00:03:49]                                          target_arch = "arm")),
[00:03:49]           all(target_os = "l4re", target_arch = "x86_64"),
[00:03:49]           all(target_os = "openbsd", target_arch = "aarch64"),
[00:03:49]           all(target_os = "fuchsia", target_arch = "aarch64")))
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs:36: platform-specific cfg: cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
[00:03:49]                                            target_arch = "arm",
[00:03:49]                                            target_arch = "powerpc",
[00:03:49]                                            target_arch = "powerpc64",
[00:03:49]                                            target_arch = "s390x")),
[00:03:49]               all(target_os = "android", any(target_arch = "aarch64",
[00:03:49]                                              target_arch = "arm")),
[00:03:49]               all(target_os = "l4re", target_arch = "x86_64"),
[00:03:49]               all(target_os = "openbsd", target_arch = "aarch64"),
[00:03:49]               all(target_os = "fuchsia", target_arch = "aarch64"))))
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs:60: platform-specific cfg: cfg(any(target_pointer_width = "32", windows))
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs:63: platform-specific cfg: cfg(any(target_pointer_width = "32", windows))
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs:66: platform-specific cfg: cfg(all(target_pointer_width = "64", not(windows)))
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs:69: platform-specific cfg: cfg(all(target_pointer_width = "64", not(windows)))
[00:03:49] tidy error: /checkout/src/libcore/os/raw/mod.rs contains #[test]; libcore tests must be placed inside `src/libcore/tests/`
[00:03:49] some tidy checks failed
[00:03:49] 
[00:03:49] 
[00:03:49] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:49] 
[00:03:49] 
[00:03:49] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:49] Build completed unsuccessfully in 0:00:49
[00:03:49] Build completed unsuccessfully in 0:00:49
[00:03:49] make: *** [tidy] Error 1
[00:03:49] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:02b04461
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:05de5fe2:start=1532910262562898840,finish=1532910262569517003,duration=6618163
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:20f85e7e
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0002263b
travis_time:start:0002263b
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:07bd1774
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:start:tidy
tidy check
[00:04:06] * 553 error codes
[00:04:06] * highest error code: E0710
[00:04:06] tidy error: /checkout/src/libstd/os/mod.rs:13: mismatches to previous in: ["since"]
[00:04:06] tidy error: /checkout/src/libcore/os/raw/mod.rs:24: platform-specific cfg: cfg(any(all(target_os = "linux", any(target_arch = "aarch64",
[00:04:06]                                        target_arch = "arm",
[00:04:06]                                        target_arch = "powerpc",
[00:04:06]                                        target_arch = "powerpc64",
[00:04:06]                                        target_arch = "s390x")),
[00:04:06]           all(target_os = "android", any(target_arch = "aarch64",
[00:04:06]                                          target_arch = "arm")),
[00:04:06]           all(target_os = "l4re", target_arch = "x86_64"),
[00:04:06]           all(target_os = "openbsd", target_arch = "aarch64"),
[00:04:06]           all(target_os = "fuchsia", target_arch = "aarch64")))
[00:04:06] tidy error: /checkout/src/libcore/os/raw/mod.rs:36: platform-specific cfg: cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
[00:04:06]                                            target_arch = "arm",
[00:04:06]                                            target_arch = "powerpc",
[00:04:06]                                            target_arch = "powerpc64",
[00:04:06]                                            target_arch = "s390x")),
[00:04:06]               all(target_os = "android", any(target_arch = "aarch64",
[00:04:06]                                              target_arch = "arm")),
[00:04:06]               all(target_os = "l4re", target_arch = "x86_64"),
[00:04:06]               all(target_os = "openbsd", target_arch = "aarch64"),
[00:04:06]               all(target_os = "fuchsia", target_arch = "aarch64"))))
[00:04:06] tidy error: /checkout/src/libcore/os/raw/mod.rs:60: platform-specific cfg: cfg(any(target_pointer_width = "32", windows))
[00:04:06] tidy error: /checkout/src/libcore/os/raw/mod.rs:63: platform-specific cfg: cfg(any(target_pointer_width = "32", windows))
[00:04:06] tidy error: /checkout/src/libcore/os/raw/mod.rs:66: platform-specific cfg: cfg(all(target_pointer_width = "64", not(windows)))
[00:04:06] tidy error: /checkout/src/libcore/os/raw/mod.rs:69: platform-specific cfg: cfg(all(target_pointer_width = "64", not(windows)))
[00:04:07] some tidy checks failed
[00:04:07] 
[00:04:07] 
[00:04:07] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:07] 
[00:04:07] 
[00:04:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:07] Build completed unsuccessfully in 0:00:50
[00:04:07] Build completed unsuccessfully in 0:00:50
[00:04:07] Makefile:79: recipe for target 'tidy' failed
[00:04:07] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:30f72f03
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:21e18379:start=1532911282206210989,finish=1532911282213832081,duration=7621092
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:07e84cf0
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:009ce3f1
travis_time:start:009ce3f1
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:00edbad0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jethrogb
Copy link
Contributor

This was discussed as part of RFC 1783 which was not accepted.

@kennytm kennytm added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 30, 2018
@kennytm
Copy link
Member

kennytm commented Jul 30, 2018

Is this platform-dependent? There are no extern declarations, and none of the types are architecture-specific.

There's a huge #[cfg] in the definition of c_char...

See also #46736.

@dtolnay
Copy link
Member

dtolnay commented Jul 30, 2018

This would be the first use of target_os in libcore, and the first use of target_arch that is observable in the public API i.e. not just an optimization.

#[cfg(any(all(target_os = "linux", any(target_arch = "aarch64",
                                       target_arch = "arm",
                                       target_arch = "powerpc",
                                       target_arch = "powerpc64",
                                       target_arch = "s390x")),
          all(target_os = "android", any(target_arch = "aarch64",
                                         target_arch = "arm")),
          all(target_os = "l4re", target_arch = "x86_64"),
          all(target_os = "openbsd", target_arch = "aarch64"),
          all(target_os = "fuchsia", target_arch = "aarch64")))]
pub type c_char = u8;

#[cfg(any(target_pointer_width = "32", windows))]
pub type c_long = i32;

@joshlf
Copy link
Contributor Author

joshlf commented Jul 31, 2018

Ah, I didn't realize this had already been litigated so much. I'm still in favor of the move, but I'm not going to waste more of folks' cycles on an issue that has been litigated to death.

@joshlf joshlf closed this Jul 31, 2018
@SimonSapin
Copy link
Contributor

New RFC to propose doing this for c_void (only, for now): rust-lang/rfcs#2521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants