Revert "libbpf: allow to use packaged version"

This reverts commit 82749180b2.

Getting in the way of releasing 1.20, breaking the build of a dwarves
rpm when a libbpf package is installed in a fedora 33 system:

In file included from /home/acme/rpmbuild/BUILD/dwarves-1.20/strings.c:7:
/home/acme/rpmbuild/BUILD/dwarves-1.20/pahole_strings.h:9:10: fatal error: bpf/btf.h: No such file or directory
    9 | #include <bpf/btf.h>
      |          ^~~~~~~~~~~

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-02-03 21:43:44 -03:00
parent 8fb7741692
commit 7943374ac5
9 changed files with 24 additions and 41 deletions

View File

@ -2,24 +2,9 @@ project(pahole C)
cmake_minimum_required(VERSION 2.8.12)
cmake_policy(SET CMP0005 NEW)
option(LIBBPF_EMBEDDED "Use the embedded version of libbpf instead of searching it via pkg-config" ON)
if (NOT LIBBPF_EMBEDDED)
find_package(PkgConfig)
if(PKGCONFIG_FOUND)
pkg_check_modules(LIBBPF libbpf>=0.3.0)
endif()
endif()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
if(NOT LIBBPF_FOUND)
# Allows to use 'system' style #include with both embedded and system libbpf
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
else()
INCLUDE_DIRECTORIES(${LIBBPF_INCLUDE_DIRS})
LINK_DIRECTORIES(${LIBBPF_LIBRARY_DIRS})
endif()
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
# Try to parse this later, Helio just showed me a KDE4 example to support
# x86-64 builds.
@ -71,7 +56,7 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
endif()
endif()
endif()
if(NOT LIBBPF_FOUND AND NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/bpf/src/btf.h")
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/bpf/src/btf.h")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
@ -96,24 +81,22 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64")
if (NOT LIBBPF_FOUND)
file(GLOB libbpf_sources "lib/bpf/src/*.c")
add_library(bpf OBJECT ${libbpf_sources})
set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1)
target_include_directories(bpf PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include)
endif()
file(GLOB libbpf_sources "lib/bpf/src/*.c")
add_library(bpf OBJECT ${libbpf_sources})
set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1)
target_include_directories(bpf PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings
ctf_encoder.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c libbtf.c
dwarf_loader.c dutil.c elf_symtab.c rbtree.c)
if (NOT LIBBPF_FOUND)
list(APPEND dwarves_LIB_SRCS $<TARGET_OBJECTS:bpf>)
endif()
add_library(dwarves SHARED ${dwarves_LIB_SRCS})
add_library(dwarves SHARED ${dwarves_LIB_SRCS} $<TARGET_OBJECTS:bpf>)
set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1)
set_target_properties(dwarves PROPERTIES INTERFACE_LINK_LIBRARIES "")
target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBBPF_LIBRARIES})
target_include_directories(dwarves PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES})
set(dwarves_emit_LIB_SRCS dwarves_emit.c)
add_library(dwarves_emit SHARED ${dwarves_emit_LIB_SRCS})

View File

@ -11,12 +11,12 @@
#include "dwarves.h"
#include "libbtf.h"
#include "lib/bpf/include/uapi/linux/btf.h"
#include "lib/bpf/src/libbpf.h"
#include "hash.h"
#include "elf_symtab.h"
#include "btf_encoder.h"
#include <linux/btf.h>
#include <bpf/libbpf.h>
#include <ctype.h> /* for isalpha() and isalnum() */
#include <stdlib.h> /* for qsort() and bsearch() */
#include <inttypes.h>

View File

@ -20,12 +20,12 @@
#include <string.h>
#include <limits.h>
#include <libgen.h>
#include <linux/btf.h>
#include <zlib.h>
#include <gelf.h>
#include "libbtf.h"
#include "lib/bpf/include/uapi/linux/btf.h"
#include "dutil.h"
#include "dwarves.h"

View File

@ -1 +0,0 @@
../bpf/src

View File

@ -16,11 +16,12 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdarg.h>
#include <linux/btf.h>
#include <bpf/btf.h>
#include <bpf/libbpf.h>
#include "libbtf.h"
#include "lib/bpf/include/uapi/linux/btf.h"
#include "lib/bpf/include/linux/err.h"
#include "lib/bpf/src/btf.h"
#include "lib/bpf/src/libbpf.h"
#include "dutil.h"
#include "gobuffer.h"
#include "dwarves.h"

View File

@ -11,7 +11,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <bpf/btf.h>
#include "lib/bpf/src/btf.h"
struct btf_elf {
void *priv;

View File

@ -16,7 +16,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <bpf/libbpf.h>
#include "dwarves_reorganize.h"
#include "dwarves.h"
@ -24,6 +23,7 @@
#include "ctf_encoder.h"
#include "btf_encoder.h"
#include "libbtf.h"
#include "lib/bpf/src/libbpf.h"
static bool btf_encode;
static bool ctf_encode;

View File

@ -6,7 +6,7 @@
Copyright (C) 2008 Arnaldo Carvalho de Melo <acme@redhat.com>
*/
#include <bpf/btf.h>
#include "lib/bpf/src/btf.h"
typedef unsigned int strings_t;

View File

@ -13,9 +13,9 @@
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#include <bpf/libbpf.h>
#include "dutil.h"
#include "lib/bpf/src/libbpf.h"
struct strings *strings__new(void)
{