diff options
author | Khyber Sen <khyber@google.com> | 2024-02-20 12:35:52 +0000 |
---|---|---|
committer | Khyber Sen <khyber@google.com> | 2024-02-22 20:38:41 +0000 |
commit | b1fdf6dfac7e8b7ce7102f74b6df630b45d22700 (patch) | |
tree | 064374652bc5f5091d9002344274ade9fc754b53 | |
parent | 655aa7a62ef9d7455aba7e4563a0d967ce72a1fc (diff) | |
download | libc-b1fdf6dfac7e8b7ce7102f74b6df630b45d22700.tar.gz |
Support #[no_std] trusty kernel by disabling unneeded trusty-sys and libc-trusty depsemu-34-3-release
For `trusty-sys`, this is done by adding a `trusty_sys` feature for its few uses.
Test: build.py
Bug: 304850822
Change-Id: Ide028fde7dfd8003d27fb1753b7fb7b60ba92b86
-rw-r--r-- | patches/rules.mk.diff | 16 | ||||
-rw-r--r-- | patches/trusty.patch | 6 | ||||
-rw-r--r-- | rules.mk | 11 | ||||
-rw-r--r-- | src/trusty.rs | 4 |
4 files changed, 32 insertions, 5 deletions
diff --git a/patches/rules.mk.diff b/patches/rules.mk.diff index d44c11fe..e9ebe30d 100644 --- a/patches/rules.mk.diff +++ b/patches/rules.mk.diff @@ -1,8 +1,8 @@ diff --git a/rules.mk b/rules.mk -index 92f34db68..08cf2d6c3 100644 +index b2ae04d7..0cd09394 100644 --- a/rules.mk +++ b/rules.mk -@@ -24,5 +24,12 @@ +@@ -24,5 +24,21 @@ MODULE_RUSTFLAGS += \ --cfg 'libc_ptr_addr_of' \ --cfg 'libc_underscore_const_names' \ --cfg 'libc_union' \ @@ -11,6 +11,16 @@ index 92f34db68..08cf2d6c3 100644 +MODULE_LIBRARY_DEPS := \ + trusty/user/base/lib/libcompiler_builtins-rust \ + trusty/user/base/lib/libcore-rust \ ++ ++ifeq ($(call TOBOOL,$(TRUSTY_USERSPACE)),true) ++ ++MODULE_RUSTFLAGS += \ ++ --cfg 'feature="trusty_sys"' \ ++ ++MODULE_LIBRARY_DEPS += \ + trusty/user/base/lib/libc-trusty \ + trusty/user/base/lib/trusty-sys \ - ++ ++endif + + include make/library.mk diff --git a/patches/trusty.patch b/patches/trusty.patch index 77de58ca..1599f06e 100644 --- a/patches/trusty.patch +++ b/patches/trusty.patch @@ -20,12 +20,16 @@ new file mode 100644 index 000000000..140fa6dfe --- /dev/null +++ a/src/trusty.rs -@@ -0,0 +1,85 @@ +@@ -0,0 +1,89 @@ ++#[cfg(feature = "trusty_sys")] +extern crate trusty_sys; + +pub use core::ffi::c_void; + ++#[cfg(feature = "trusty_sys")] +pub const PROT_READ: i32 = self::trusty_sys::MMAP_FLAG_PROT_READ as i32; ++ ++#[cfg(feature = "trusty_sys")] +pub const PROT_WRITE: i32 = self::trusty_sys::MMAP_FLAG_PROT_WRITE as i32; + +pub type size_t = usize; @@ -1,4 +1,4 @@ -# This file is generated by cargo2rulesmk.py --run --config cargo2rulesmk.json --features .. +# This file is generated by cargo2rulesmk.py --run --config cargo2rulesmk.json. # Do not modify this file as changes will be overridden on upgrade. LOCAL_DIR := $(GET_LOCAL_DIR) @@ -29,7 +29,16 @@ MODULE_RUSTFLAGS += \ MODULE_LIBRARY_DEPS := \ trusty/user/base/lib/libcompiler_builtins-rust \ trusty/user/base/lib/libcore-rust \ + +ifeq ($(call TOBOOL,$(TRUSTY_USERSPACE)),true) + +MODULE_RUSTFLAGS += \ + --cfg 'feature="trusty_sys"' \ + +MODULE_LIBRARY_DEPS += \ trusty/user/base/lib/libc-trusty \ trusty/user/base/lib/trusty-sys \ +endif + include make/library.mk diff --git a/src/trusty.rs b/src/trusty.rs index eca27bf7..c8d297d2 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -1,8 +1,12 @@ +#[cfg(feature = "trusty_sys")] extern crate trusty_sys; pub use core::ffi::c_void; +#[cfg(feature = "trusty_sys")] pub const PROT_READ: i32 = self::trusty_sys::MMAP_FLAG_PROT_READ as i32; + +#[cfg(feature = "trusty_sys")] pub const PROT_WRITE: i32 = self::trusty_sys::MMAP_FLAG_PROT_WRITE as i32; pub type size_t = usize; |