Skip to content

Commit

Permalink
sparse: Fix build with DPDK v23.11-rc1.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
david-marchand committed Oct 13, 2023
1 parent b6687b9 commit 60e5c86
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sparse/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
23 changes: 23 additions & 0 deletions include/sparse/ia32intrin.h
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 60e5c86

Please sign in to comment.