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

Actions/clang action test #13

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/clang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build with Clang/LLVM

on: pull_request

jobs:
clang-build-cancel:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
clang-build:
runs-on: ubuntu-latest
needs: clang-build-cancel
container:
image: zephyrprojectrtos/ci:v0.17.0-alpha2
options: '--entrypoint /bin/bash'
strategy:
fail-fast: false
matrix:
subset: [1]
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.12.4
CLANG_ROOT_DIR: /usr/lib/llvm-12
MATRIX_SIZE: 1
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Update PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: west setup
run: |
west init -l . || true
west update

- name: Check Environment
run: |
cmake --version
${CLANG_ROOT_DIR}/bin/clang --version
gcc --version
ls -la

- name: Run Tests with Twister
run: |
#source zephyr-env.sh
export ZEPHYR_BASE=${PWD}
export ZEPHYR_TOOLCHAIN_VARIANT=llvm
./scripts/twister --inline-logs -N -v --integration -p native_posix -T tests/kernel/common --subset ${{matrix.subset}}/${MATRIX_SIZE} --retry-failed 3

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results (Subset ${{ matrix.subset }})
path: twister-out/twister.xml

publish-test-results:
name: "Publish Unit Tests Results"
needs: clang-build
runs-on: ubuntu-20.04
# the build-and-test job might be skipped, we don't need to run this job then
if: success() || failure()

steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Display structure of downloaded files
run: ls -R

- name: Publish Unit Test Results
uses: EnricoMi/[email protected]
with:
check_name: Unit Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "**/twister.xml"
4 changes: 1 addition & 3 deletions cmake/toolchain/llvm/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})

if("${ARCH}" STREQUAL "posix")
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
endif()
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")

message(STATUS "Found toolchain: host (clang/ld)")
13 changes: 13 additions & 0 deletions include/sys/cbprintf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ union z_cbprintf_hdr {
void *raw;
};

/* When using clang additional warning needs to be suppressed since each
* argument of fmt string is used for sizeof() which results in the warning
* if argument is a stirng literal. Suppression is added here instead of
* the macro which generates the warning to not slow down the compiler.
*/
#if __clang__ == 1
#define Z_CBPRINTF_SUPPRESS_SIZEOF_ARRAY_DECAY \
_Pragma("GCC diagnostic ignored \"-Wsizeof-array-decay\"")
#else
#define Z_CBPRINTF_SUPPRESS_SIZEOF_ARRAY_DECAY
#endif

/** @brief Statically package a formatted string with arguments.
*
* @param buf buffer. If null then only length is calculated.
Expand All @@ -277,6 +289,7 @@ union z_cbprintf_hdr {
do { \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wpointer-arith\"") \
Z_CBPRINTF_SUPPRESS_SIZEOF_ARRAY_DECAY \
BUILD_ASSERT(!IS_ENABLED(CONFIG_XTENSA) || \
(IS_ENABLED(CONFIG_XTENSA) && \
!(_align_offset % CBPRINTF_PACKAGE_ALIGNMENT)), \
Expand Down
2 changes: 2 additions & 0 deletions include/toolchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <toolchain/xcc.h>
#elif defined(__CCAC__)
#include <toolchain/mwdt.h>
#elif defined(__llvm__)
#include <toolchain/llvm.h>
#elif defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__))
#include <toolchain/gcc.h>
#else
Expand Down
15 changes: 15 additions & 0 deletions include/toolchain/llvm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2021 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_
#define ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_


#define __no_optimization __attribute__((optnone))
#include <toolchain/gcc.h>


#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_ */
3 changes: 1 addition & 2 deletions tests/kernel/common/src/timeout_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ static void thread(void *p1, void *p2, void *p3)
uintptr_t id = (uintptr_t)p1;

k_timer_status_sync(&timer[id]);
printk("%s %" PRIxPTR " synced on timer %" PRIxPTR "\n",
__func__, id, id);
printk("%s %lu synced on timer %lu\n", __func__, POINTER_TO_UINT(id), POINTER_TO_UINT(id));

/* no need to protect cur, all threads have the same prio */
results[cur++] = id;
Expand Down
1 change: 1 addition & 0 deletions tests/lib/cmsis_dsp/filtering/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ common:
- mps2_an521
- native_posix
tags: cmsis_dsp
toolchain_exclude: llvm

tests:
libraries.cmsis_dsp.filtering:
Expand Down
4 changes: 4 additions & 0 deletions tests/subsys/fs/multi-fs/src/test_common_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <fs/fs.h>
#include "test_common.h"

#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

int test_rmdir(const char *dir_path);

int test_mkdir(const char *dir_path, const char *file)
Expand Down