Skip to content

Commit

Permalink
Restore debuggability (#1200)
Browse files Browse the repository at this point in the history
* make: add real debug

add __assert_fail implementation for ring

* cli: remove duplicate -s flag clap

* make: remove obsolete comment

* fixup! make: add real debug

* clippy: remove unnecessary unsafe block

* enclave-runtime: add __assert_fail implementation for ring / ring-xous

This is a necessary addition to have ring / ring-xous compile in debug
mode. Teaclave added their implementation, but it no longer gets linked
for some reason.
See #1200 for more
details.
  • Loading branch information
OverOrion authored Mar 7, 2023
1 parent 472ba55 commit d1de190
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ endif
endif

ifeq ($(SGX_DEBUG), 1)
# we build with cargo --release, even in SGX DEBUG mode
SGX_COMMON_CFLAGS += -O0 -g -ggdb
# cargo sets this automatically, cannot use 'debug'
OUTPUT_PATH := release
CARGO_TARGET := --release
OUTPUT_PATH := debug
CARGO_TARGET :=
else
SGX_COMMON_CFLAGS += -O2
OUTPUT_PATH := release
Expand Down
4 changes: 2 additions & 2 deletions enclave-runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Rust_Enclave_Files := $(wildcard src/*.rs) $(wildcard ../stf/src/*.rs)
RUSTFLAGS :="-C target-feature=+avx2"

ifeq ($(SGX_DEBUG), 1)
OUTPUT_PATH := release
CARGO_TARGET := --release
OUTPUT_PATH := debug
CARGO_TARGET :=
else
OUTPUT_PATH := release
CARGO_TARGET := --release
Expand Down
14 changes: 14 additions & 0 deletions enclave-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,17 @@ fn internal_trigger_parentchain_block_import() -> Result<()> {
triggered_import_dispatcher.import_all()?;
Ok(())
}

// This is required, because `ring` / `ring-xous` would not compile without it non-release (debug) mode.
// See #1200 for more details.
#[cfg(debug_assertions)]
#[no_mangle]
pub extern "C" fn __assert_fail(
__assertion: *const u8,
__file: *const u8,
__line: u32,
__function: *const u8,
) -> ! {
use core::intrinsics::abort;
abort()
}
3 changes: 0 additions & 3 deletions service/src/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ subcommands:
args:
- skip-ra:
long: skip-ra
short: s
help: skip remote attestation. Set this flag if running enclave in SW mode
- shard:
required: false
Expand All @@ -115,12 +114,10 @@ subcommands:
args:
- shard:
long: shard
short: s
required: false
help: shard identifier base58 encoded. Defines the state that this worker shall operate on. Default is mrenclave
- skip-ra:
long: skip-ra
short: s
help: skip remote attestation. Set this flag if running enclave in SW mode
- shielding-key:
about: Get the public RSA3072 key from the TEE to be used to encrypt requests
Expand Down

0 comments on commit d1de190

Please sign in to comment.