Skip to content

Commit

Permalink
WIP remove autoconf.h
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
axel-h committed Jul 18, 2024
1 parent 107cd14 commit eeffc75
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 70 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ description indicates whether it is SOURCE-COMPATIBLE, BINARY-COMPATIBLE, or BRE
* General minor build system improvements and clean-up
* Set up automated tests for CI and GitHub pull requests on seL4
* Add vulnerability disclosure policy
* Removed autoconf.h for kernel and libsel4.

### Upgrade Notes

Expand Down
27 changes: 6 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,30 +350,16 @@ include_directories(
#

include_directories($<TARGET_PROPERTY:kernel_Config,INTERFACE_INCLUDE_DIRECTORIES>)
# The kernel expects to be able to include an 'autoconf.h' file at the moment.
# So lets generate one for it to use
# TODO: use the kernel_Config directly
generate_autoconf(kernel_autoconf "kernel")
include_directories($<TARGET_PROPERTY:kernel_autoconf,INTERFACE_INCLUDE_DIRECTORIES>)

# Target for the config / autoconf headers. This is what all the other generated headers
# Target for the config headers. This is what all the other generated headers
# can depend upon
add_custom_target(
kernel_config_headers
DEPENDS
kernel_autoconf_Gen
kernel_autoconf
kernel_Config
kernel_Gen
)
add_custom_target(kernel_config_headers DEPENDS kernel_Config kernel_Gen)

# Target for all generated headers. We start with just all the config / autoconf headers
# Target for all generated headers. We start with just all the config headers
add_custom_target(kernel_headers DEPENDS kernel_config_headers)

# Build up a list of generated files. needed for dependencies in custom commands
get_generated_files(gen_files_list kernel_autoconf_Gen)
get_generated_files(gen_files2 kernel_Gen)
list(APPEND gen_files_list "${gen_files2}")
get_generated_files(gen_files_list kernel_Gen)

#
# C source generation
Expand Down Expand Up @@ -673,7 +659,7 @@ add_executable(kernel.elf EXCLUDE_FROM_ALL ${asm_sources} kernel_all.c)
target_include_directories(kernel.elf PRIVATE ${config_dir})
target_include_directories(kernel.elf PRIVATE include)
target_include_directories(kernel.elf PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
target_link_libraries(kernel.elf PRIVATE kernel_Config kernel_autoconf)
target_link_libraries(kernel.elf PRIVATE kernel_Config)
set_property(TARGET kernel.elf APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-T ${linker_lds_path} ")
set_target_properties(kernel.elf PROPERTIES LINK_DEPENDS "${linker_lds_path}")
add_dependencies(kernel.elf circular_includes)
Expand Down Expand Up @@ -711,10 +697,9 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
"${CMAKE_CURRENT_BINARY_DIR}/libsel4/include/"
"${CMAKE_CURRENT_BINARY_DIR}/libsel4/arch_include/${KernelArch}/"
"${CMAKE_CURRENT_BINARY_DIR}/libsel4/sel4_arch_include/${KernelSel4Arch}/"
# The following directories install the autoconf headers
# The following directories install the configuration headers
"${CMAKE_CURRENT_BINARY_DIR}/gen_config/"
"${CMAKE_CURRENT_BINARY_DIR}/libsel4/gen_config/"
"${CMAKE_CURRENT_BINARY_DIR}/libsel4/autoconf/"
DESTINATION libsel4/include
FILES_MATCHING
PATTERN "*.h"
Expand Down
15 changes: 15 additions & 0 deletions include/sel4/gen_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2024, Codasip GmbH
*
* SPDX-License-Identifier: GPL-2.0-only
*/

#pragma once

/*
* This file exists, because the kernel includes the libsel4 headers, which
* need the header file 'sel4/gen_config.h' with the libsel4 configuration. When
* compiling the kernel, the libsel4 configuration has not been created yet, so
* we provide a dummy file here. This is fine because nothing in the libsel4
* configuration is relevant for the kernel.
*/
15 changes: 2 additions & 13 deletions libsel4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ RequireFile(SYSCALL_STUB_GEN_PATH syscall_stub_gen.py PATHS tools)

add_config_library(sel4 "${configure_string}")

# Currently we use autoconf.h, so generate one of those
generate_autoconf(sel4_autoconf "kernel;sel4")

gen_invocation_header(
OUTPUT "include/sel4/invocation.h"
XML "include/interfaces/object-api.xml"
Expand Down Expand Up @@ -83,16 +80,8 @@ set(
)
include_directories("${source_header_dirs}")

# Add the include directory of autoconf.h to the cflags for the bitfield generation
include_directories("$<TARGET_PROPERTY:sel4_autoconf,INTERFACE_INCLUDE_DIRECTORIES>")

function(genbf target_prefix pbf_location bf_location header_output)
get_generated_files(gen_list sel4_autoconf_Gen)
cppfile(
"${pbf_location}" ${target_prefix}_pbf "${bf_location}"
EXTRA_FLAGS -P
EXTRA_DEPS sel4_autoconf_Gen ${gen_list}
)
cppfile("${pbf_location}" ${target_prefix}_pbf "${bf_location}" EXTRA_FLAGS -P)
GenHBFTarget(
"libsel4"
${target_prefix}_h
Expand Down Expand Up @@ -176,7 +165,7 @@ add_custom_target(
)

add_library(sel4 src/sel4_bootinfo.c)
target_link_libraries(sel4 PRIVATE kernel_Config sel4_Config sel4_autoconf)
target_link_libraries(sel4 PRIVATE kernel_Config sel4_Config)
target_include_directories(
sel4
PUBLIC
Expand Down
6 changes: 4 additions & 2 deletions libsel4/include/sel4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

/* Compile-time configuration parameters. Might be set by the build system. */
/* Kernel configuration */
#include <kernel/gen_config.h>

#include <autoconf.h>
/* Libsel4 configuration */
#include <sel4/gen_config.h>
34 changes: 0 additions & 34 deletions tools/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -575,40 +575,6 @@ macro(get_generated_files output target)
get_property(${output} TARGET ${target} PROPERTY GENERATED_FILES)
endmacro(get_generated_files)

# This rule tries to emulate an 'autoconf' header. autoconf generated headers
# were previously used as configuration, so this rule provides a way for previous
# applications and libraries to build without modification. The config_list
# is a list of 'prefix' values that have been passed to add_config_library
# This generates a library with ${targetname} that when linked against
# will allow code to simply #include <autoconf.h>
function(generate_autoconf targetname config_list)
set(link_list "")
set(gen_list "")
set(config_header_contents "\n#pragma once\n\n")
foreach(config IN LISTS config_list)
list(APPEND link_list "${config}_Config")
get_generated_files(gens ${config}_Gen)
list(APPEND gen_list ${gens})
string(APPEND config_header_contents "#include <${config}/gen_config.h>\n")
endforeach()
set(config_dir "${CMAKE_CURRENT_BINARY_DIR}/autoconf")
set(config_file "${config_dir}/autoconf.h")

file(GENERATE OUTPUT "${config_file}" CONTENT "${config_header_contents}")
add_custom_target(${targetname}_Gen DEPENDS "${config_file}" ${gen_list})
add_library(${targetname} INTERFACE)
target_link_libraries(${targetname} INTERFACE ${link_list})
target_include_directories(${targetname} INTERFACE "${config_dir}")
add_dependencies(${targetname} ${targetname}_Gen ${config_file} ${gen_list})
# Set our GENERATED_FILES property to include the GENERATED_FILES of all of our input
# configurations, as well as the files we generated
set_property(
TARGET ${targetname}_Gen
APPEND
PROPERTY GENERATED_FILES "${config_file}" ${gen_list}
)
endfunction(generate_autoconf)

# Macro that allows for appending to a specified list only if all the supplied conditions are true
macro(list_append_if list dep)
set(list_append_local_list ${${list}})
Expand Down

0 comments on commit eeffc75

Please sign in to comment.