Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.

Commit acb7a72

Browse files
committed
uemu: Enable -DNDEBUG for Release build
1 parent 55fc76a commit acb7a72

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2525
# Compiler flags
2626
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Werror -Wno-unused-command-line-argument -Wno-implicit-fallthrough -Wno-unused-result")
2727
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Werror -Wno-sign-compare -Wno-unused-command-line-argument -Wno-implicit-fallthrough -Wno-unused-result")
28-
set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Werror -flto -Wno-unused-command-line-argument -Wno-implicit-fallthrough -Wno-unused-result")
29-
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -Werror -Wno-sign-compare -flto -Wno-unused-command-line-argument -Wno-implicit-fallthrough -Wno-unused-result")
28+
set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Werror -flto -Wno-unused-command-line-argument -Wno-implicit-fallthrough -Wno-unused-result -DNDEBUG")
29+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -Werror -Wno-sign-compare -flto -Wno-unused-command-line-argument -Wno-implicit-fallthrough -Wno-unused-result -DNDEBUG")
3030

3131
# Prefer LLVM tools when using Clang (helps with -flto)
3232
if (CMAKE_C_COMPILER_ID MATCHES "Clang")

src/utils/alarm.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include <cassert>
18+
#include <cstdlib>
1819
#include <cstring>
1920
#include <signal.h>
2021
#include <sys/time.h>
@@ -58,15 +59,22 @@ void alarm_init() {
5859
};
5960

6061
int ret = sigaction(SIGVTALRM, &s, nullptr);
61-
assert(ret == 0);
62+
if (ret)
63+
goto fail;
6264

6365
struct itimerval it;
6466
memset(&it, 0, sizeof(it));
6567
it.it_value.tv_sec = 0;
6668
it.it_value.tv_usec = 1000000 / TIMER_HZ;
6769
it.it_interval = it.it_value;
6870
ret = setitimer(ITIMER_VIRTUAL, &it, NULL);
69-
assert(ret == 0);
71+
if (ret)
72+
goto fail;
7073

7174
log_info("Alarm initialized");
75+
return;
76+
77+
fail:
78+
log_error("Alarm init failed");
79+
exit(EXIT_FAILURE);
7280
}

tests/bus-tests/simple-uart.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@
1919

2020
#include "simple-uart.h"
2121

22-
uint64_t simple_uart_read(uint64_t addr, size_t n) {
23-
uint64_t off = addr - SIMPLE_UART_BASE_ADDR;
24-
assert(off == 0);
25-
return -1;
26-
}
22+
uint64_t simple_uart_read(uint64_t addr, size_t n) { return -1; }
2723

2824
void simple_uart_write(uint64_t addr, uint64_t value, size_t n) {
29-
uint64_t off = addr - SIMPLE_UART_BASE_ADDR;
30-
assert(off == 0 && n == 4);
3125
putchar((int)value);
3226
}

0 commit comments

Comments
 (0)