Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: silence "LOAD segment with RWX permissions" warning #167

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 2
indent_style = space

[lib/**]
indent_size = 2
indent_style = space
53 changes: 53 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: compile

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
release:
- "ubuntu:20.04"
- "ubuntu:22.04"
- "ubuntu:24.04"
- "ubuntu:rolling"
- "debian:oldstable-slim"
- "debian:stable-slim"
- "debian:testing-slim"
- "debian:unstable-slim"

steps:
- uses: actions/checkout@v4

- name: Prepare ${{ matrix.release }} container
run: |
podman version
podman run --name stable -di --userns=keep-id:uid=1000,gid=1000 -v "$PWD":/home -w /home ${{ matrix.release }} bash
podman exec -i stable uname -a
podman exec -i stable id
podman exec -i -u root stable apt update
podman exec -e DEBIAN_FRONTEND='noninteractive' -i -u root stable apt install -o APT::Install-Suggests=false -qy \
clang \
cmake \
gcc-arm-none-eabi \
git \
make

- name: Configure & Build with arm-none-eabi-gcc
env:
toolchain: arm-none-eabi-gcc
run: |
podman exec -i stable cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=cmake/${toolchain}.cmake -B build-${toolchain}
podman exec -i stable cmake --build build-${toolchain}

- name: Show logs
if: ${{ failure() }}
run: |
for log in build-*/CMakeFiles/{CMakeOutput.log,CMakeConfigureLog.yaml}; do \
if [ -e ${log} ]; then \
echo "---------------- ${log} ----------------"; \
cat ${log}; \
fi; \
done
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Check C Styling
steps:
- name: Checkout this commit
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: uncrustify check
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.18)
project(candleLightFirmware C ASM)
include(CheckLinkerFlag)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down Expand Up @@ -39,6 +40,11 @@ add_link_options(
LINKER:--print-memory-usage
)

check_linker_flag(C "LINKER:--no-warn-rwx-segments" LINKER_SUPPORTS_NO_WARN_RWX_SEGMENTS)
if(LINKER_SUPPORTS_NO_WARN_RWX_SEGMENTS)
add_link_options(LINKER:--no-warn-rwx-segments)
endif()

add_subdirectory(libs/STM32_HAL)
add_subdirectory(libs/STM32_USB_Device_Library)
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake )
Expand Down
8 changes: 8 additions & 0 deletions cmake/arm-none-eabi-clang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_C_COMPILER clang)
set(CMAKE_C_COMPILER_TARGET arm-none-eabi)

SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
8 changes: 8 additions & 0 deletions cmake/arm-none-eabi-gcc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_C_COMPILER_TARGET arm-none-eabi)

SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
24 changes: 12 additions & 12 deletions include/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
#define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x))

#define WRITE_ONCE(x,v) \
do { \
barrier(); \
ACCESS_ONCE(x) = (v); \
barrier(); \
} while (0)
do { \
barrier(); \
ACCESS_ONCE(x) = (v); \
barrier(); \
} while (0)

#define READ_ONCE(x) \
({ \
({ \
__typeof(x) __var = ({ \
barrier(); \
ACCESS_ONCE(x); \
Expand All @@ -77,21 +77,21 @@
#define sizeof_field(_s, _m) sizeof(((_s *)0)->_m)

#define container_of(ptr, type, member) \
({ \
({ \
__typeof(((type *)0)->member) *_p = (ptr); \
(type *)((char *)_p - offsetof(type, member)); \
})

#define struct_size(ptr, field, num) \
(offsetof(__typeof(*(ptr)), field) + sizeof((ptr)->field[0]) * (num))
(offsetof(__typeof(*(ptr)), field) + sizeof((ptr)->field[0]) * (num))

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

#define DECLARE_FLEX_ARRAY(_t, _n) \
struct { \
struct { } __dummy_ ## _n; \
_t _n[0]; \
}
struct { \
struct { } __dummy_ ## _n; \
_t _n[0]; \
}

#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
Expand Down
Loading
Loading