Skip to content

Commit bab4405

Browse files
committed
fix to give -ggdb option if debug is enabled
Signed-off-by: Jun Kimura <junkxdev@gmail.com>
1 parent 6c0d920 commit bab4405

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

samples/hello-rust/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Paths
22
SGX_SDK ?= /opt/sgxsdk
3+
DEBUG := 0
4+
ifeq ($(DEBUG), 0)
5+
PROFILE := release
6+
CARGO_FLAGS := --release
7+
else
8+
PROFILE := debug
9+
export SGX_DEBUG := 1
10+
endif
311
SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign
4-
Enclave_SO := enclave/target/x86_64-unknown-unknown-sgx/release/enclave.so
12+
Enclave_SO := enclave/target/x86_64-unknown-unknown-sgx/$(PROFILE)/enclave.so
513
Signed_Enclave := bin/enclave.signed.so
614
Enclave_Config := enclave/Enclave.config.xml
715
Enclave_Key := enclave/Enclave_private.pem
8-
App_Binary := app/target/release/app
16+
App_Binary := app/target/$(PROFILE)/app
917

1018
.PHONY: all build build-enclave build-app sign clean run
1119

@@ -15,11 +23,11 @@ build: build-enclave build-app
1523

1624
build-enclave:
1725
@echo "Building enclave (including .so generation)..."
18-
cd enclave && cargo sgx build --release
26+
cd enclave && cargo sgx build $(CARGO_FLAGS)
1927

2028
build-app:
2129
@echo "Building app..."
22-
cd app && cargo build --release
30+
cd app && cargo build $(CARGO_FLAGS)
2331
@echo "Copying app binary to bin/..."
2432
@cp $(App_Binary) bin/
2533

sgx-build/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ impl SgxBuilder {
352352
// Debug/Release specific flags
353353
if self.debug {
354354
build
355+
.flag("-ggdb")
355356
.flag("-O0")
356357
.flag("-g")
357358
.define("DEBUG", None)

unit-test/Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# Paths
22
SGX_SDK ?= /opt/sgxsdk
3+
DEBUG := 0
4+
ifeq ($(DEBUG), 0)
5+
PROFILE := release
6+
CARGO_FLAGS := --release
7+
else
8+
PROFILE := debug
9+
export SGX_DEBUG := 1
10+
endif
311
SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign
4-
Enclave_SO := enclave/target/x86_64-unknown-unknown-sgx/release/enclave.so
12+
Enclave_SO := enclave/target/x86_64-unknown-unknown-sgx/$(PROFILE)/enclave.so
513
Signed_Enclave := bin/enclave.signed.so
614
Enclave_Config := enclave/Enclave.config.xml
715
Enclave_Key := enclave/Enclave_private.pem
8-
App_Binary := app/target/release/app
16+
App_Binary := app/target/$(PROFILE)/app
917

10-
.PHONY: all build build-enclave build-app sign clean
18+
.PHONY: all build build-enclave build-app sign clean run
1119

1220
all: build sign
1321

1422
build: build-enclave build-app
1523

1624
build-enclave:
1725
@echo "Building enclave (including .so generation)..."
18-
cd enclave && cargo sgx build --release
26+
cd enclave && cargo sgx build $(CARGO_FLAGS)
1927

2028
build-app:
2129
@echo "Building app..."
22-
cd app && cargo build --release
30+
cd app && cargo build $(CARGO_FLAGS)
2331
@echo "Copying app binary to bin/..."
2432
@cp $(App_Binary) bin/
2533

@@ -34,3 +42,6 @@ clean:
3442
@rm -rf bin/*
3543
@cd enclave && cargo clean
3644
@cd app && cargo clean
45+
46+
run:
47+
@cd bin && ./app

0 commit comments

Comments
 (0)