What kind of error is -Werror=format-truncation?

JetPack Version Used: 4.4
Kernel Version Used: 4.4

Hello. I’m bhyim

I received the source_release.tbz2 file through the Jetson/TX2 SPI - eLinux.org site.
Uncompressed and moved to /sources/kernel/kernel-4.4 to:

Note: The following sites have been referenced in the course of performing:
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/kernel_custom.html#wwpID0E0LD0HA

$ TEGRA_KERNEL_OUT= ----- > output directory path settings
$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
→ Here’s the error, and here’s the following:

make[1]: Entering directory ‘/home/nvidia/sources/kernel/build’
** GEN ./Makefile**
** HOSTCC scripts/kconfig/zconf.tab.o**
scripts/kconfig/zconf.tab.c:211:10: fatal error: zconf.hash.c: No such file or directory
** #include “zconf.hash.c”**
^~~~~~~~~~~~~~
compilation terminated.
scripts/Makefile.host:108: recipe for target ‘scripts/kconfig/zconf.tab.o’ fai led
make[2]: *** [scripts/kconfig/zconf.tab.o] Error 1
/home/nvidia/sources/kernel/kernel-4.4/Makefile:542: recipe for target ‘tegra1 8_defconfig’ failed
make[1]: *** [tegra18_defconfig] Error 2
make[1]: Leaving directory ‘/home/nvidia/sources/kernel/build’
Makefile:150: recipe for target ‘sub-make’ failed
make: *** [sub-make] Error 2

the action I took

  1. modify tegra_decinfig to tegra18_deconfig >> fail
  2. delete ARCH=arm64 O=$TEGRA_KERNEL_OUT >> fail
  3. Run maketegra18_deconfig >> Successful
    Successfully obtained .config file.

After successful, perform the following command:
$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4 → fail

Error is…

arch/arm64/kernel/topology.c: In function ‘parse_cluster’:
arch/arm64/kernel/topology.c:114:40: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 3 [-Werror=format-truncation=]
snprintf(name, sizeof(name), “cluster%d”, i);
^~
arch/arm64/kernel/topology.c:114:32: note: directive argument in the range [0, 2147483647]
snprintf(name, sizeof(name), “cluster%d”, i);
^~~~~~~~~~~
arch/arm64/kernel/topology.c:114:3: note: ‘snprintf’ output between 9 and 18 bytes into a destination of size 10
snprintf(name, sizeof(name), “cluster%d”, i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

skip…

arch/arm64/kernel/topology.c:59:3: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 10
snprintf(name, sizeof(name), “thread%d”, i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
scripts/Makefile.build:261: recipe for target ‘arch/arm64/kernel/topology.o’ failed
make[1]: *** [arch/arm64/kernel/topology.o] Error 1
Makefile:973: recipe for target ‘arch/arm64/kernel’ failed
make: *** [arch/arm64/kernel] Error 2

I couldn’t start from here.

I have a question about this.

  1. I would like to know the exact reason and solution for the “-Werror=format-truncation” error.

  2. JetPack 4.3 is a convenient kernel compilation using scripts from buildJetsonKernel.
    Is there no script available in JetPack 4.4 like this?

Thank you to those who help me.

Were you cross compiling from an Ubuntu 18.04 host PC? Or native compiling from the Jetson? More details on the environment would help. FYI, if a configuration is incorrect, then all kinds of odd failures can occur since you might end up trying to compile incompatible features for such a case.

Note that building target tegra_defconfig should never fail if using unedited source code, and if building in the correct environment (for instance, you would not mention ARCH= if building natively, and would always need the ARCH= if cross compiling).

Could you follow the l4t document to download the source to clarify.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/kernel_custom.html#wwpID0E0WD0HA

okay. I’ll try again.

Thank you.

I’ll try again slowly from the beginning.

Thank you.