After DPDK started relying on compiler intrinsics in rte_cycles.h,
sparse raises the following warning:

libtool: compile:  env REAL_CC=gcc "CHECK=sparse -Wsparse-error
        -I ../../include/sparse -I ../../include -m64
        -I /usr/local/include -I /usr/include/x86_64-linux-gnu
        " cgcc -target=x86_64 -target=host_os_specs -D__MMX__=1
        -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE2__=1 -D__SSE__=1
        -DHAVE_CONFIG_H -I. -I../.. -I ../../include -I ./include
        -I ../../lib -I ./lib -Wstrict-prototypes -Wall -Wextra
        -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security
        -Wswitch-enum -Wunused-parameter -Wbad-function-cast
        -Wcast-align -Wstrict-prototypes -Wold-style-definition
        -Wmissing-prototypes -Wmissing-field-initializers
        -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses
        -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value
        -Wduplicated-cond -Wshadow -Wmultistatement-macros
        -Wcast-align=strict -mssse3 -include rte_config.h -mrtm
        -I/home/runner/work/ovs/ovs/dpdk-dir/include -Werror
        -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/netdev-dpdk.lo -MD -MP
        -MF lib/.deps/netdev-dpdk.Tpo -c ../../lib/netdev-dpdk.c
        -o lib/netdev-dpdk.o
../../lib/netdev-dpdk.c: note: in included file (through
        /usr/lib/gcc/x86_64-linux-gnu/9//include/x86intrin.h,
        /home/runner/work/ovs/ovs/dpdk-dir/include/rte_cycles.h,
        /home/runner/work/ovs/ovs/dpdk-dir/include/rte_spinlock.h, ...):
/usr/lib/gcc/x86_64-linux-gnu/9//include/ia32intrin.h:114:10: error:
        undefined identifier '__builtin_ia32_rdtsc'

Provide an empty implementation of __builtin_ia32_rdtsc() builtin.

Signed-off-by: David Marchand <[email protected]>
---
Note: I am sending this early, but please wait before merging this in
dpdk-latest as v23.11-rc1 is far from being ready.
I am expecting more changes in EAL headers and I'll update this patch
if hitting more issues.

---
 include/sparse/automake.mk  |  1 +
 include/sparse/ia32intrin.h | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 include/sparse/ia32intrin.h

diff --git a/include/sparse/automake.mk b/include/sparse/automake.mk
index e966371192..c1229870bb 100644
--- a/include/sparse/automake.mk
+++ b/include/sparse/automake.mk
@@ -4,6 +4,7 @@ noinst_HEADERS += \
         include/sparse/arpa/inet.h \
         include/sparse/bits/floatn.h \
         include/sparse/assert.h \
+        include/sparse/ia32intrin.h \
         include/sparse/math.h \
         include/sparse/numa.h \
         include/sparse/netinet/in.h \
diff --git a/include/sparse/ia32intrin.h b/include/sparse/ia32intrin.h
new file mode 100644
index 0000000000..5045bf38d9
--- /dev/null
+++ b/include/sparse/ia32intrin.h
@@ -0,0 +1,23 @@
+/* Copyright (c) 2023 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CHECKER__
+#error "Use this header only with sparse.  It is not a correct implementation."
+#endif
+
+#define __builtin_ia32_rdtsc() (unsigned long long) 0
+
+/* Get actual <ia32intrin.h> definitions for us to annotate and build on. */
+#include_next <ia32intrin.h>
-- 
2.41.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to