gromero commented on pull request #9068:
URL: https://github.com/apache/tvm/pull/9068#issuecomment-929195909


   > @gromero i don't think we can use the C++ attribute since we are in C. I'm 
okay with solution 1 you proposed, since `NDEBUG`'s relation is 
[documented](https://en.cppreference.com/w/cpp/error/assert) in the standard C 
lib docs.
   
   It just happens that we can use `[[maybe_unused]]` in `crt_runtime_api.c` 
yep, I've tested it, but I confess I wasn't expecting it to work either, look:
   
   ```
   gromero@amd:/tmp/x17/build$ fgrep IsConti  
/tmp/x17/crt/src/runtime/crt/common/crt_runtime_api.c 
   static bool IsContiguous(const DLTensor* arr) {
     assert(IsContiguous(from) && IsContiguous(to));
   gromero@amd:/tmp/x17/build$ ccache 
/home/gromero/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc 
-DBOARD_FLASH_SIZE="CONFIG_FLASH_SIZE*1024" 
-DBUILD_VERSION=zephyr-v2.5.0-65-g79d575bf3552 -DCPU_MIMXRT1052DVL6B -DKERNEL 
-DNDEBUG -DXIP_BOOT_HEADER_DCD_ENABLE=1 -DXIP_BOOT_HEADER_ENABLE=1 
-D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START 
-D__ZEPHYR__=1 -I/tmp/x17/common -I/tmp/x17/crt_config -I/tmp/x17/crt/include 
-I/home/gromero/zephyrproject/zephyr/include 
-I/tmp/x17/build/zephyr/include/generated 
-I/home/gromero/zephyrproject/zephyr/soc/arm/nxp_imx/rt 
-I/home/gromero/zephyrproject/zephyr/lib/libc/newlib/include 
-I/home/gromero/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include 
-I/home/gromero/zephyrproject/modules/hal/nxp/mcux/devices/MIMXRT1052 
-I/home/gromero/zephyrproject/modules/hal/nxp/mcux/drivers/imx/. -Os -imacros 
/tmp/x17/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common 
-g -mcpu=cortex-m7 -mthumb -mabi=aapcs -mfpu=fpv5-d16 -mfloat-ab
 i=hard -imacros 
/home/gromero/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall 
-Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign 
-Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable 
-Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic 
-fno-strict-overflow -fno-reorder-functions -fno-defer-pop 
-fmacro-prefix-map=/tmp/x17=CMAKE_SOURCE_DIR 
-fmacro-prefix-map=/home/gromero/zephyrproject/zephyr=ZEPHYR_BASE 
-fmacro-prefix-map=/home/gromero/zephyrproject=WEST_TOPDIR -ffunction-sections 
-fdata-sections -specs=nano.specs -std=c99 -MD -MT 
CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj -MF 
CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj.d -o 
CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj -c 
/tmp/x17/crt/src/runtime/crt/common/crt_runtime_api.c
   /tmp/x17/crt/src/runtime/crt/common/crt_runtime_api.c:108:13: warning: 
'IsContiguous' defined but not used [-Wunused-function]
     108 | static bool IsContiguous(const DLTensor* arr) {
         |             ^~~~~~~~~~~~
   gromero@amd:/tmp/x17/build$ vim 
/tmp/x17/crt/src/runtime/crt/common/crt_runtime_api.c +108
   gromero@amd:/tmp/x17/build$ fgrep IsConti  
/tmp/x17/crt/src/runtime/crt/common/crt_runtime_api.c 
   [[maybe_unused]] static bool IsContiguous(const DLTensor* arr) {
     assert(IsContiguous(from) && IsContiguous(to));
   gromero@amd:/tmp/x17/build$ ccache 
/home/gromero/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc 
-DBOARD_FLASH_SIZE="CONFIG_FLASH_SIZE*1024" 
-DBUILD_VERSION=zephyr-v2.5.0-65-g79d575bf3552 -DCPU_MIMXRT1052DVL6B -DKERNEL 
-DNDEBUG -DXIP_BOOT_HEADER_DCD_ENABLE=1 -DXIP_BOOT_HEADER_ENABLE=1 
-D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START 
-D__ZEPHYR__=1 -I/tmp/x17/common -I/tmp/x17/crt_config -I/tmp/x17/crt/include 
-I/home/gromero/zephyrproject/zephyr/include 
-I/tmp/x17/build/zephyr/include/generated 
-I/home/gromero/zephyrproject/zephyr/soc/arm/nxp_imx/rt 
-I/home/gromero/zephyrproject/zephyr/lib/libc/newlib/include 
-I/home/gromero/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include 
-I/home/gromero/zephyrproject/modules/hal/nxp/mcux/devices/MIMXRT1052 
-I/home/gromero/zephyrproject/modules/hal/nxp/mcux/drivers/imx/. -Os -imacros 
/tmp/x17/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common 
-g -mcpu=cortex-m7 -mthumb -mabi=aapcs -mfpu=fpv5-d16 -mfloat-ab
 i=hard -imacros 
/home/gromero/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall 
-Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign 
-Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable 
-Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic 
-fno-strict-overflow -fno-reorder-functions -fno-defer-pop 
-fmacro-prefix-map=/tmp/x17=CMAKE_SOURCE_DIR 
-fmacro-prefix-map=/home/gromero/zephyrproject/zephyr=ZEPHYR_BASE 
-fmacro-prefix-map=/home/gromero/zephyrproject=WEST_TOPDIR -ffunction-sections 
-fdata-sections -specs=nano.specs -std=c99 -MD -MT 
CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj -MF 
CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj.d -o 
CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj -c 
/tmp/x17/crt/src/runtime/crt/common/crt_runtime_api.c
   gromero@amd:/tmp/x17/build$ 
   ```
   :)
   
   But I agree that 1. will be a better fit since I can't explain why 
`[[maybe_unused]]` works here. :+1: 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to