Makefile: Avoid using built-in stpcpy during clang build
authorErwan Velu <e.velu@criteo.com>
Wed, 2 Jun 2021 14:15:59 +0000 (16:15 +0200)
committerErwan Velu <e.velu@criteo.com>
Wed, 2 Jun 2021 15:26:11 +0000 (17:26 +0200)
Since clang 12, during the clang build, noticed by the CI, the linking
fails as clang optimize some string functions to stpcpy.

  LINK fio
lld-link: error: undefined symbol: stpcpy
>>> referenced by C:\projects\fio\options.c:5305
>>>               options.o:(fio_options_parse)

Two possible implementations :
- Adding stpcpy in fio as the kernel did : https://lore.kernel.org/lkml/20200815002417.1512973-1-ndesaulniers@google.com/T/
- Disable the implicit stpcpy

To avoid adding code into fio, the latter option was used.

Signed-off-by: Erwan Velu <e.velu@criteo.com>
Makefile

index ef3173737100f78c1a24c2eb0d06872b89b9dca9..f57569d5f66461f85a54a69e53d4f161a2d6fba8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,11 @@ ifdef CONFIG_PDB
   LDFLAGS += -fuse-ld=lld $(LINK_PDBFILE)
 endif
 
+# If clang, do not use builtin stpcpy as it breaks the build
+ifeq ($(CC),clang)
+  FIO_CFLAGS += -fno-builtin-stpcpy
+endif
+
 ifdef CONFIG_GFIO
   PROGS += gfio
 endif