all: Move all warning flags to a common CMake variable
This commit is contained in:
parent
4e48d024d9
commit
d07b00a892
@ -28,6 +28,14 @@ set(CMAKE_FIND_ROOT_PATH ${LUNA_ROOT}/toolchain/${LUNA_ARCH}-luna)
|
|||||||
|
|
||||||
message(STATUS "Configuring Luna for ${LUNA_ARCH}")
|
message(STATUS "Configuring Luna for ${LUNA_ARCH}")
|
||||||
|
|
||||||
|
set(COMMON_FLAGS -Wall -Wextra -Werror -Wvla
|
||||||
|
-Wdisabled-optimization -Wformat=2 -Winit-self
|
||||||
|
-Wmissing-include-dirs -Wswitch-default -Wcast-qual
|
||||||
|
-Wundef -Wcast-align -Wwrite-strings -Wlogical-op
|
||||||
|
-Wredundant-decls -Wshadow -Wconversion
|
||||||
|
-fno-asynchronous-unwind-tables -fno-omit-frame-pointer
|
||||||
|
-std=c++20 -fno-rtti -fno-exceptions)
|
||||||
|
|
||||||
add_subdirectory(libluna)
|
add_subdirectory(libluna)
|
||||||
add_subdirectory(libos)
|
add_subdirectory(libos)
|
||||||
add_subdirectory(libc)
|
add_subdirectory(libc)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
function(luna_app SOURCE_FILE APP_NAME)
|
function(luna_app SOURCE_FILE APP_NAME)
|
||||||
add_executable(${APP_NAME} ${SOURCE_FILE})
|
add_executable(${APP_NAME} ${SOURCE_FILE})
|
||||||
target_compile_options(${APP_NAME} PRIVATE -Os -Wall -Wextra -pedantic -Werror -Wno-write-strings)
|
target_compile_options(${APP_NAME} PRIVATE -Os ${COMMON_FLAGS} -Wno-write-strings)
|
||||||
add_dependencies(${APP_NAME} libc)
|
add_dependencies(${APP_NAME} libc)
|
||||||
target_include_directories(${APP_NAME} PRIVATE ${LUNA_BASE}/usr/include)
|
target_include_directories(${APP_NAME} PRIVATE ${LUNA_BASE}/usr/include)
|
||||||
install(TARGETS ${APP_NAME} DESTINATION ${LUNA_ROOT}/initrd/bin)
|
install(TARGETS ${APP_NAME} DESTINATION ${LUNA_ROOT}/initrd/bin)
|
||||||
|
@ -21,7 +21,7 @@ static Result<Vector<char*>> split_command_into_argv(const char* cmd)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char* segment = strtok(NULL, " \n");
|
segment = strtok(NULL, " \n");
|
||||||
TRY(result.try_append(segment));
|
TRY(result.try_append(segment));
|
||||||
|
|
||||||
if (segment == NULL) return result;
|
if (segment == NULL) return result;
|
||||||
|
@ -76,13 +76,8 @@ target_link_libraries(moon luna-freestanding)
|
|||||||
|
|
||||||
target_compile_definitions(moon PRIVATE IN_MOON)
|
target_compile_definitions(moon PRIVATE IN_MOON)
|
||||||
|
|
||||||
target_compile_options(moon PRIVATE -Wall -Wextra -Werror -Wvla -Wsign-conversion)
|
target_compile_options(moon PRIVATE ${COMMON_FLAGS})
|
||||||
target_compile_options(moon PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
|
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel -ffreestanding)
|
||||||
target_compile_options(moon PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
|
||||||
target_compile_options(moon PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
|
||||||
target_compile_options(moon PRIVATE -fno-rtti -ffreestanding -fno-exceptions)
|
|
||||||
target_compile_options(moon PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
|
|
||||||
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel)
|
|
||||||
|
|
||||||
if("${LUNA_ARCH}" MATCHES "x86_64")
|
if("${LUNA_ARCH}" MATCHES "x86_64")
|
||||||
target_compile_options(moon PRIVATE -mno-red-zone)
|
target_compile_options(moon PRIVATE -mno-red-zone)
|
||||||
|
@ -40,8 +40,13 @@ target_link_libraries(bare_libc PUBLIC luna)
|
|||||||
|
|
||||||
target_include_directories(bare_libc PUBLIC include/)
|
target_include_directories(bare_libc PUBLIC include/)
|
||||||
|
|
||||||
target_compile_options(bare_libc PRIVATE -Os -Wall -Wextra -Werror -nostdlib)
|
target_compile_options(bare_libc PRIVATE ${COMMON_FLAGS})
|
||||||
target_compile_options(bare_libc PRIVATE -fno-exceptions -fno-rtti)
|
|
||||||
|
if(LUNA_DEBUG_SYMBOLS)
|
||||||
|
target_compile_options(bare_libc PRIVATE -ggdb)
|
||||||
|
else()
|
||||||
|
target_compile_options(bare_libc PRIVATE -Os)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_options(bare_libc PRIVATE -nostdlib)
|
target_link_options(bare_libc PRIVATE -nostdlib)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ extern "C"
|
|||||||
long rc = syscall(SYS_getdents, stream->_fd, &ent, 1);
|
long rc = syscall(SYS_getdents, stream->_fd, &ent, 1);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
errno = -rc;
|
errno = (int)-rc;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,19 +278,19 @@ extern "C"
|
|||||||
|
|
||||||
int vfprintf(FILE* stream, const char* format, va_list ap)
|
int vfprintf(FILE* stream, const char* format, va_list ap)
|
||||||
{
|
{
|
||||||
usize rc = cstyle_format(
|
usize count = cstyle_format(
|
||||||
format,
|
format,
|
||||||
[](char c, void* f) -> Result<void> {
|
[](char c, void* f) -> Result<void> {
|
||||||
int rc = fputc(c, (FILE*)f);
|
int rc = fputc(c, (FILE*)f);
|
||||||
if (rc == EOF) return err(errno);
|
if (rc == EOF) return err(errno);
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
stream, ap)
|
stream, ap)
|
||||||
.value_or(-1);
|
.value_or(-1);
|
||||||
|
|
||||||
if (rc == (usize)-1) return -1;
|
if (count == (usize)-1) return -1;
|
||||||
|
|
||||||
return (int)rc;
|
return (int)count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fprintf(FILE* stream, const char* format, ...)
|
int fprintf(FILE* stream, const char* format, ...)
|
||||||
|
@ -33,24 +33,15 @@ set(SOURCES
|
|||||||
|
|
||||||
add_library(luna-freestanding ${FREESTANDING_SOURCES})
|
add_library(luna-freestanding ${FREESTANDING_SOURCES})
|
||||||
target_compile_definitions(luna-freestanding PRIVATE USE_FREESTANDING)
|
target_compile_definitions(luna-freestanding PRIVATE USE_FREESTANDING)
|
||||||
target_compile_options(luna-freestanding PRIVATE -Os -Wall -Wextra -Werror -Wvla)
|
target_compile_options(luna-freestanding PRIVATE ${COMMON_FLAGS})
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self -Wsign-conversion)
|
target_compile_options(luna-freestanding PRIVATE -nostdlib -mcmodel=kernel -ffreestanding)
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
|
||||||
target_compile_options(luna-freestanding PRIVATE -fno-rtti -ffreestanding -fno-exceptions)
|
|
||||||
target_compile_options(luna-freestanding PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
|
|
||||||
target_compile_options(luna-freestanding PRIVATE -nostdlib -mcmodel=kernel)
|
|
||||||
|
|
||||||
target_include_directories(luna-freestanding PUBLIC include/)
|
target_include_directories(luna-freestanding PUBLIC include/)
|
||||||
target_include_directories(luna-freestanding PRIVATE ${LUNA_ROOT}/kernel/src)
|
target_include_directories(luna-freestanding PRIVATE ${LUNA_ROOT}/kernel/src)
|
||||||
set_target_properties(luna-freestanding PROPERTIES CXX_STANDARD 20)
|
set_target_properties(luna-freestanding PROPERTIES CXX_STANDARD 20)
|
||||||
|
|
||||||
add_library(luna ${SOURCES})
|
add_library(luna ${SOURCES})
|
||||||
target_compile_options(luna PRIVATE -Os -Wall -Wextra -Werror -Wvla)
|
target_compile_options(luna PRIVATE ${COMMON_FLAGS})
|
||||||
target_compile_options(luna PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
|
|
||||||
target_compile_options(luna PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
|
||||||
target_compile_options(luna PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
|
||||||
target_compile_options(luna PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -std=c++20 -fno-rtti -fno-exceptions)
|
|
||||||
target_include_directories(luna PUBLIC include/)
|
target_include_directories(luna PUBLIC include/)
|
||||||
target_include_directories(luna PUBLIC ${LUNA_BASE}/usr/include)
|
target_include_directories(luna PUBLIC ${LUNA_BASE}/usr/include)
|
||||||
|
|
||||||
@ -65,4 +56,7 @@ if(LUNA_DEBUG_SYMBOLS)
|
|||||||
message(STATUS "Building Luna with debug symbols")
|
message(STATUS "Building Luna with debug symbols")
|
||||||
target_compile_options(luna PRIVATE -ggdb)
|
target_compile_options(luna PRIVATE -ggdb)
|
||||||
target_compile_options(luna-freestanding PRIVATE -ggdb)
|
target_compile_options(luna-freestanding PRIVATE -ggdb)
|
||||||
|
else()
|
||||||
|
target_compile_options(luna PRIVATE -Os)
|
||||||
|
target_compile_options(luna-freestanding PRIVATE -Os)
|
||||||
endif()
|
endif()
|
||||||
|
@ -8,11 +8,7 @@ set(SOURCES
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(os ${SOURCES})
|
add_library(os ${SOURCES})
|
||||||
target_compile_options(os PRIVATE -Os -Wall -Wextra -Werror -Wvla)
|
target_compile_options(os PRIVATE ${COMMON_FLAGS})
|
||||||
target_compile_options(os PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
|
|
||||||
target_compile_options(os PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
|
||||||
target_compile_options(os PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
|
||||||
target_compile_options(os PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -std=c++20 -fno-rtti -fno-exceptions)
|
|
||||||
target_include_directories(os PUBLIC include/)
|
target_include_directories(os PUBLIC include/)
|
||||||
target_include_directories(os PUBLIC ${LUNA_BASE}/usr/include)
|
target_include_directories(os PUBLIC ${LUNA_BASE}/usr/include)
|
||||||
|
|
||||||
@ -23,4 +19,6 @@ endif()
|
|||||||
if(LUNA_DEBUG_SYMBOLS)
|
if(LUNA_DEBUG_SYMBOLS)
|
||||||
message(STATUS "Building libOS with debug symbols")
|
message(STATUS "Building libOS with debug symbols")
|
||||||
target_compile_options(os PRIVATE -ggdb)
|
target_compile_options(os PRIVATE -ggdb)
|
||||||
|
else()
|
||||||
|
target_compile_options(os PRIVATE -Os)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user