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

Conversation

Projects
None yet
8 participants
@joshlf
Copy link
Contributor

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

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jul 30, 2018

r? @aidanhs

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

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jul 30, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jul 30, 2018

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)

@joshlf joshlf force-pushed the joshlf:raw-core branch from 4f1b588 to 2b483e7 Jul 30, 2018

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jul 30, 2018

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

This comment has been minimized.

Copy link
Contributor

jethrogb commented Jul 30, 2018

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

@jethrogb jethrogb referenced this pull request Jul 30, 2018

Open

libc dependencies #13

@kennytm kennytm added the T-libs label Jul 30, 2018

@kennytm

This comment has been minimized.

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.

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Jul 30, 2018

Previously:

I’m personally not very convinced by the arguments against this move.

@dtolnay

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Aug 9, 2018

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
You can’t perform that action at this time.