Skip to content

Commit

Permalink
build: Fix enabling of build warnings, and handle most warnings disco…
Browse files Browse the repository at this point in the history
…vered.
  • Loading branch information
rpavlik committed May 13, 2020
1 parent dc35446 commit 6482076
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 36 deletions.
9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,17 @@ set_target_properties(xr_global_generated_files PROPERTIES FOLDER ${CODEGEN_FOLD
set(COMMON_GENERATED_OUTPUT ${GENERATED_OUTPUT})
if(NOT MSVC)
include(CheckCXXCompilerFlag)
foreach(FLAG -Wall -Werror=unused-parameter -Werror=unused-argument)
include(CheckCCompilerFlag)
foreach(FLAG -Wall -Werror=unused-parameter -Werror=unused-argument -Wpointer-arith)
string(REGEX REPLACE "[^A-Za-z0-9]" "" _flagvar "${FLAG}")
check_cxx_compiler_flag(${FLAG} SUPPORTS_${_flagvar})
if(SUPPORTS_WARNING_${_flagvar})
if(SUPPORTS_${_flagvar})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
endif()
check_c_compiler_flag(${FLAG} SUPPORTS_C_${_flagvar})
if(SUPPORTS_C_${_flagvar})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
endif()
endforeach()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
endif()
Expand Down
4 changes: 0 additions & 4 deletions src/api_layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,16 @@ if(WIN32)
set_target_properties(copy-core_validation-def-file PROPERTIES FOLDER ${HELPER_FOLDER})
elseif(APPLE)
# Apple api_dump-specific information
target_compile_options(XrApiLayer_api_dump PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_api_dump PROPERTIES LINK_FLAGS "-Wl")

# Apple core_validation-specific information
target_compile_options(XrApiLayer_core_validation PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_core_validation PROPERTIES LINK_FLAGS "-Wl")

else()
# Linux api_dump-specific information
target_compile_options(XrApiLayer_api_dump PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_api_dump PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")

# Linux core_validation-specific information
target_compile_options(XrApiLayer_core_validation PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_core_validation PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")
endif()

Expand Down
9 changes: 9 additions & 0 deletions src/common/gfxwrapper_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3190,6 +3190,10 @@ ksGpuWindowEvent ksGpuWindow_ProcessEvents(ksGpuWindow *window) {

#elif defined(OS_LINUX_WAYLAND)

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
static void _keyboard_keymap_cb(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size) { close(fd); }
static void _keyboard_modifiers_cb(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed,
uint32_t mods_latched, uint32_t mods_locked, uint32_t group) {}
Expand Down Expand Up @@ -3337,11 +3341,16 @@ static void _registry_cb(void *data, struct wl_registry *registry, uint32_t id,

static void _registry_remove_cb(void *data, struct wl_registry *registry, uint32_t id) {}

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

const struct wl_registry_listener registry_listener = {_registry_cb, _registry_remove_cb};

bool ksGpuWindow_Create(ksGpuWindow *window, ksDriverInstance *instance, const ksGpuQueueInfo *queueInfo, const int queueIndex,
const ksGpuSurfaceColorFormat colorFormat, const ksGpuSurfaceDepthFormat depthFormat,
const ksGpuSampleCount sampleCount, const int width, const int height, const bool fullscreen) {
(void)queueIndex;
memset(window, 0, sizeof(ksGpuWindow));

window->display = NULL;
Expand Down
6 changes: 1 addition & 5 deletions src/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(
openxr_loader
PRIVATE -Wall
-Wextra
-Wno-unused-parameter
-Wno-missing-field-initializers
-Wpointer-arith
PRIVATE -Wextra
-fno-strict-aliasing
-fno-builtin-memcmp
"$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>"
Expand Down
7 changes: 5 additions & 2 deletions src/scripts/validation_layer_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ def outputValidationHeaderInfo(self):
validation_header_info += '\n// Current API version of the Core Validation API Layer\n#define XR_CORE_VALIDATION_API_VERSION '
validation_header_info += self.api_version_define
validation_header_info += '\n'
validation_header_info += '#if defined(__GNUC__)\n'
validation_header_info += '#pragma GCC diagnostic push\n'
validation_header_info += '#pragma GCC diagnostic ignored "-Wunused-parameter"\n'
validation_header_info += '#pragma GCC diagnostic ignored "-Wunused-variable"\n'
validation_header_info += '#endif\n'

validation_header_info += '\n// Externs for Core Validation\n'
validation_header_info += self.outputInfoMapDeclarations(extern=True)
Expand Down Expand Up @@ -1001,8 +1006,6 @@ def writeValidateStructNextCheck(self, struct_type, struct_name, member, indent)
validate_struct_next += self.writeIndent(indent)
validate_struct_next += '} else if (NEXT_CHAIN_RESULT_DUPLICATE_STRUCT == next_result) {\n'
validate_struct_next += self.writeIndent(indent + 1)
validate_struct_next += 'char struct_type_buffer[XR_MAX_STRUCTURE_NAME_SIZE];\n'
validate_struct_next += self.writeIndent(indent + 1)
validate_struct_next += 'std::string error_message = "Multiple structures of the same type(s) in \\"next\\" chain for ";\n'
validate_struct_next += self.writeIndent(indent + 1)
validate_struct_next += 'error_message += "%s : ";\n' % struct_type
Expand Down
2 changes: 0 additions & 2 deletions src/tests/hello_xr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(NOT D3D_DIRECTXCOLORS_INCLUDE_DIR)
target_compile_definitions(hello_xr PRIVATE -DMISSING_DIRECTX_COLORS)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(hello_xr PRIVATE -Wall)
endif()

if(Vulkan_LIBRARY)
Expand Down
4 changes: 0 additions & 4 deletions src/tests/list/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ if(MSVC)
target_compile_options(runtime_list PRIVATE /Zc:wchar_t /Zc:forScope /W4 /WX)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(runtime_list PRIVATE -Wall)
endif()

set_target_properties(runtime_list PROPERTIES FOLDER ${TESTS_FOLDER})
set_target_properties(runtime_list PROPERTIES OUTPUT_NAME openxr_runtime_list)

Expand Down
4 changes: 1 addition & 3 deletions src/tests/loader_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif()

elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(
loader_test PRIVATE -Wall -Wno-unused-function -Wno-format-truncation
)
# No special options needed.
else()
message(FATAL_ERROR "Unsupported Platform")
endif()
Expand Down
1 change: 0 additions & 1 deletion src/tests/loader_test/test_layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
)
set_target_properties(copy-test-def-file PROPERTIES FOLDER ${HELPER_FOLDER})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(XrApiLayer_test PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_test PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")
gen_xr_layer_json(
${PROJECT_BINARY_DIR}/src/tests/loader_test/resources/layers/XrApiLayer_test.json
Expand Down
15 changes: 8 additions & 7 deletions src/tests/loader_test/test_layers/layer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
extern "C" {
std::map<XrInstance, PFN_xrGetInstanceProcAddr> g_next_gipa_map;

XRAPI_ATTR XrResult XRAPI_CALL LayerTestXrCreateInstance(const XrInstanceCreateInfo *info, XrInstance *instance) {
XRAPI_ATTR XrResult XRAPI_CALL LayerTestXrCreateInstance(const XrInstanceCreateInfo * /* info */, XrInstance * /* instance */) {
// In a layer, LayerTestXrCreateApiLayerInstance is called instead of this function. This should not be called.
return XR_ERROR_FUNCTION_UNSUPPORTED;
}
Expand Down Expand Up @@ -118,6 +118,7 @@ LAYER_EXPORT XrResult xrNegotiateLoaderApiLayerInterface(const XrNegotiateLoader
return XR_ERROR_INITIALIZATION_FAILED;
}

(void)layerName;
layerRequest->layerInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
layerRequest->layerApiVersion = XR_MAKE_VERSION(0, 1, 0);
layerRequest->getInstanceProcAddr = LayerTestXrGetInstanceProcAddr;
Expand All @@ -127,9 +128,9 @@ LAYER_EXPORT XrResult xrNegotiateLoaderApiLayerInterface(const XrNegotiateLoader
}

// Always fail
LAYER_EXPORT XrResult TestlayerAlwaysFailNegotiateLoaderApiLayerInterface(const XrNegotiateLoaderInfo *loaderInfo,
const char *layerName,
XrNegotiateApiLayerRequest *layerRequest) {
LAYER_EXPORT XrResult TestlayerAlwaysFailNegotiateLoaderApiLayerInterface(const XrNegotiateLoaderInfo * /* loaderInfo */,
const char * /* layerName */,
XrNegotiateApiLayerRequest * /* layerRequest */) {
return XR_ERROR_INITIALIZATION_FAILED;
}

Expand All @@ -148,7 +149,7 @@ LAYER_EXPORT XrResult TestLayerNullGipaNegotiateLoaderApiLayerInterface(const Xr
loaderInfo->minApiVersion < XR_MAKE_VERSION(0, 1, 0) || loaderInfo->minApiVersion >= XR_MAKE_VERSION(1, 1, 0)) {
return XR_ERROR_INITIALIZATION_FAILED;
}

(void)layerName;
layerRequest->layerInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
layerRequest->layerApiVersion = XR_MAKE_VERSION(0, 1, 0);
layerRequest->getInstanceProcAddr = nullptr;
Expand All @@ -171,7 +172,7 @@ LAYER_EXPORT XrResult TestLayerInvalidInterfaceNegotiateLoaderApiLayerInterface(
loaderInfo->minApiVersion < XR_MAKE_VERSION(0, 1, 0) || loaderInfo->minApiVersion >= XR_MAKE_VERSION(1, 1, 0)) {
return XR_ERROR_INITIALIZATION_FAILED;
}

(void)layerName;
layerRequest->layerInterfaceVersion = 0;
layerRequest->layerApiVersion = XR_MAKE_VERSION(0, 1, 0);
layerRequest->getInstanceProcAddr = reinterpret_cast<PFN_xrGetInstanceProcAddr>(LayerTestXrGetInstanceProcAddr);
Expand All @@ -194,7 +195,7 @@ LAYER_EXPORT XrResult TestLayerInvalidApiNegotiateLoaderApiLayerInterface(const
loaderInfo->minApiVersion < XR_MAKE_VERSION(0, 1, 0) || loaderInfo->minApiVersion >= XR_MAKE_VERSION(1, 1, 0)) {
return XR_ERROR_INITIALIZATION_FAILED;
}

(void)layerName;
layerRequest->layerInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
layerRequest->layerApiVersion = 0;
layerRequest->getInstanceProcAddr = reinterpret_cast<PFN_xrGetInstanceProcAddr>(LayerTestXrGetInstanceProcAddr);
Expand Down
1 change: 0 additions & 1 deletion src/tests/loader_test/test_runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
)
set_target_properties(copy-test_runtime-def-file PROPERTIES FOLDER ${HELPER_FOLDER})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(test_runtime PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(test_runtime PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")
gen_xr_runtime_json(
${PROJECT_BINARY_DIR}/src/tests/loader_test/resources/runtimes/test_runtime.json
Expand Down
21 changes: 16 additions & 5 deletions src/tests/loader_test/test_runtimes/runtime_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@

extern "C" {

XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrCreateInstance(const XrInstanceCreateInfo *info, XrInstance *instance) {
XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrCreateInstance(const XrInstanceCreateInfo * /* info */, XrInstance *instance) {
*instance = (XrInstance)1;
return XR_SUCCESS;
}

XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrDestroyInstance(XrInstance instance) { return XR_SUCCESS; }
XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrDestroyInstance(XrInstance /* instance */) { return XR_SUCCESS; }

XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrEnumerateInstanceExtensionProperties(const char *layerName,
uint32_t propertyCapacityInput,
Expand All @@ -62,13 +62,20 @@ XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrEnumerateInstanceExtensionProperties
return XR_SUCCESS;
}

XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrGetSystem(XrInstance instance, const XrSystemGetInfo *getInfo, XrSystemId *systemId) {
XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrGetSystem(XrInstance instance, const XrSystemGetInfo * /* getInfo */,
XrSystemId *systemId) {
if (instance == XR_NULL_HANDLE) {
return XR_ERROR_HANDLE_INVALID;
}
*systemId = 1;
return XR_SUCCESS;
}

XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrGetSystemProperties(XrInstance instance, XrSystemId systemId,
XrSystemProperties *properties) {
if (instance == XR_NULL_HANDLE) {
return XR_ERROR_HANDLE_INVALID;
}
if (systemId != 1) {
return XR_ERROR_SYSTEM_INVALID;
}
Expand All @@ -89,7 +96,11 @@ XRAPI_ATTR XrResult XRAPI_CALL RuntimeTestXrGetInstanceProcAddr(XrInstance insta
*function = reinterpret_cast<PFN_xrVoidFunction>(RuntimeTestXrEnumerateInstanceExtensionProperties);
} else if (0 == strcmp(name, "xrCreateInstance")) {
*function = reinterpret_cast<PFN_xrVoidFunction>(RuntimeTestXrCreateInstance);
} else if (0 == strcmp(name, "xrDestroyInstance")) {
};
if (instance == XR_NULL_HANDLE) {
return XR_ERROR_HANDLE_INVALID;
}
if (0 == strcmp(name, "xrDestroyInstance")) {
*function = reinterpret_cast<PFN_xrVoidFunction>(RuntimeTestXrDestroyInstance);
} else if (0 == strcmp(name, "xrGetSystem")) {
*function = reinterpret_cast<PFN_xrVoidFunction>(RuntimeTestXrGetSystem);
Expand Down Expand Up @@ -126,7 +137,7 @@ RUNTIME_EXPORT XRAPI_ATTR XrResult XRAPI_CALL xrNegotiateLoaderRuntimeInterface(

// Always fail
RUNTIME_EXPORT XRAPI_ATTR XrResult XRAPI_CALL TestRuntimeAlwaysFailNegotiateLoaderRuntimeInterface(
const XrNegotiateLoaderInfo *loaderInfo, XrNegotiateRuntimeRequest *runtimeRequest) {
const XrNegotiateLoaderInfo * /* loaderInfo */, XrNegotiateRuntimeRequest * /* runtimeRequest */) {
return XR_ERROR_INITIALIZATION_FAILED;
}

Expand Down

0 comments on commit 6482076

Please sign in to comment.