Repository navigation
Add self-compilation tools and CI runners [GH #219] #237
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
Open
mborland
wants to merge
1
commit into
edgcpp:main
Choose a base branch
from
mborland:219
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+727
−104
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Part of the EDG Compiler Project, under the Apache License v2.0 with LLVM | ||
| # Exceptions. | ||
| # See https://edgcpp.org/LICENSE.txt for license information. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| # | ||
| # Build SoftFloat (at the commit pinned in | ||
| # dev_tools/docker/softfloat/SOFTFLOAT_COMMIT) with MSVC, leaving the headers | ||
| # in softfloat/include and the library in softfloat/lib/softfloat.lib under | ||
| # the workspace. A cached build is reused when one is available. The MSVC | ||
| # developer environment must already be set up (e.g., with | ||
| # ilammy/msvc-dev-cmd). | ||
|
|
||
| name: Build SoftFloat (MSVC) | ||
| description: Build (or restore from the cache) SoftFloat with MSVC. | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Read SoftFloat commit pin | ||
| id: softfloat-pin | ||
| shell: bash | ||
| run: | | ||
| echo "commit=$(tr -d '[:space:]' < dev_tools/docker/softfloat/SOFTFLOAT_COMMIT)" \ | ||
| >> "${GITHUB_OUTPUT}" | ||
|
|
||
| - name: Cache SoftFloat | ||
| id: cache-softfloat | ||
| uses: actions/cache@v6 | ||
| with: | ||
| path: softfloat | ||
| key: softfloat-msvc-win-${{ steps.softfloat-pin.outputs.commit }} | ||
|
|
||
| - name: Build SoftFloat (MSVC) | ||
| if: steps.cache-softfloat.outputs.cache-hit != 'true' | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| commit="${{ steps.softfloat-pin.outputs.commit }}" | ||
| mkdir softfloat-src | ||
| git -C softfloat-src init | ||
| git -C softfloat-src remote add origin \ | ||
| https://github.com/ucb-bar/berkeley-softfloat-3.git | ||
| git -C softfloat-src fetch --depth 1 origin "${commit}" | ||
| git -C softfloat-src checkout FETCH_HEAD | ||
|
|
||
| # EDG Windows SoftFloat build: cl + lib (not MinGW). Emit MSVC | ||
| # platform bits inline; derive sources.rsp from upstream's | ||
| # Win32-SSE2-MinGW Makefile (8086-SSE / non-FAST_INT64). | ||
| build_dir=softfloat-src/build/Win-MSVC | ||
| mkdir -p "${build_dir}" | ||
|
|
||
| cat > "${build_dir}/platform.h" <<'EOF' | ||
| /*============================================================================ | ||
| MSVC platform header for SoftFloat. Keep free of GCC-only opts | ||
| (opts-GCC.h, SOFTFLOAT_BUILTIN_CLZ, SOFTFLOAT_INTRINSIC_INT128). | ||
| =============================================================================*/ | ||
|
|
||
| #define LITTLEENDIAN 1 | ||
|
|
||
| #ifdef _MSC_VER | ||
| #define INLINE static __inline | ||
| #else | ||
| #define INLINE static inline | ||
| #endif | ||
| EOF | ||
|
|
||
| # Strip the leading spaces YAML left in the heredoc body. | ||
| sed -i 's/^ //' "${build_dir}/platform.h" | ||
|
|
||
| cat > "${build_dir}/build.bat" <<'EOF' | ||
| REM In place of a Makefile, use this batch file to create softfloat.lib | ||
| REM Source paths live in sources.rsp to avoid CreateProcess length limits. | ||
|
|
||
| set LIB=softfloat.lib | ||
| set SOFTFLOAT_OPTS=-DSOFTFLOAT_ROUND_ODD -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32 | ||
| set SPECIALIZE_TYPE=8086-SSE | ||
| set SOURCE=..\..\source | ||
| set S=%SOURCE%\ | ||
| set P=%SOURCE%\%SPECIALIZE_TYPE%\ | ||
|
|
||
| del *.obj %LIB% 2>nul | ||
| cl -nologo -c -O2 -I. -I%S% -I%P% -I%S%include %SOFTFLOAT_OPTS% @sources.rsp | ||
| if errorlevel 1 exit /b 1 | ||
| lib -nologo /out:%LIB% *.obj | ||
| if errorlevel 1 exit /b 1 | ||
| EOF | ||
| sed -i 's/^ //' "${build_dir}/build.bat" | ||
|
|
||
| python - <<'PY' | ||
| import re | ||
| from pathlib import Path | ||
|
|
||
| makefile = Path( | ||
| 'softfloat-src/build/Win32-SSE2-MinGW/Makefile' | ||
| ).read_text() | ||
|
|
||
| def section(name): | ||
| match = re.search( | ||
| rf'{name}\s*=\s*((?:.*\\\n)*.*)', makefile | ||
| ) | ||
| return re.findall(r'(\w+)\$\(OBJ\)', match.group(1)) | ||
|
|
||
| paths = ( | ||
| [fr'..\..\source\{n}.c' for n in section('OBJS_PRIMITIVES')] | ||
| + [ | ||
| fr'..\..\source\8086-SSE\{n}.c' | ||
| for n in section('OBJS_SPECIALIZE') | ||
| ] | ||
| + [fr'..\..\source\{n}.c' for n in section('OBJS_OTHERS')] | ||
| ) | ||
| Path('softfloat-src/build/Win-MSVC/sources.rsp').write_text( | ||
| '\r\n'.join(paths) + '\r\n' | ||
| ) | ||
| PY | ||
|
|
||
| cmd.exe //C "cd softfloat-src\\build\\Win-MSVC && build.bat" | ||
|
|
||
| mkdir -p softfloat/include softfloat/lib | ||
| cp softfloat-src/source/include/softfloat.h \ | ||
| softfloat-src/source/include/softfloat_types.h \ | ||
| softfloat/include/ | ||
| cp softfloat-src/build/Win-MSVC/softfloat.lib softfloat/lib/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Part of the EDG Compiler Project, under the Apache License v2.0 with LLVM | ||
| # Exceptions. | ||
| # See https://edgcpp.org/LICENSE.txt for license information. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| # | ||
| # Check that the front end can still be built from the C that its | ||
| # C-generating back end produces for the front end's own sources, which is how | ||
| # C++ code is built for a system that has only a C compiler. Each job builds | ||
| # cpfe with the host C++ compiler, uses it to translate the front end to C, | ||
| # builds cpfe-self from that C with the host C compiler, and then checks that | ||
| # cpfe-self translates the front end to the same C as cpfe (see | ||
| # src/cmake/cpfe-self/CMakeLists.txt). | ||
|
|
||
| name: Self-Compile CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| linux: | ||
| name: Linux ${{ matrix.name }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 120 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - name: GCC x64 | ||
| preset: linux-gcc-debug | ||
| build-dir: build/gcc | ||
| base: gcc | ||
| - name: GCC x32 | ||
| preset: linux-i686-gcc-debug | ||
| build-dir: build/gcc-i686 | ||
| base: gcc-i686 | ||
| - name: Clang x64 | ||
| preset: linux-clang-debug | ||
| build-dir: build/clang | ||
| base: clang | ||
| container: | ||
| image: docker.io/edgcpp/ci-runner:latest | ||
| defaults: | ||
| run: | ||
| shell: edg-container-exec "bash -eo pipefail {0}" | ||
| env: | ||
| EDG_BASE: ${{ github.workspace }}/bases/docker/dev-env/${{ matrix.base }} | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Configure ${{ matrix.preset }} | ||
| run: cmake --preset ${{ matrix.preset }} -DEDG_SELF_COMPILE=ON | ||
|
|
||
| - name: Build cpfe-self | ||
| run: cmake --build ${{ matrix.build-dir }} --target cpfe-self | ||
|
|
||
| - name: Check cpfe-self | ||
| run: cmake --build ${{ matrix.build-dir }} --target cpfe-self-check | ||
|
|
||
| windows-msvc: | ||
| name: Windows MSVC x64 | ||
| runs-on: windows-latest | ||
| timeout-minutes: 120 | ||
| env: | ||
| EDG_SOFTFLOAT_INCLUDE_PATH: ${{ github.workspace }}/softfloat/include | ||
| EDG_SOFTFLOAT_LIB_PATH: ${{ github.workspace }}/softfloat/lib/softfloat.lib | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Install Ninja | ||
| run: choco install ninja -y | ||
|
|
||
| - name: Set up MSVC developer environment | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
|
|
||
| - name: Build SoftFloat | ||
| uses: ./.github/actions/build-softfloat-msvc | ||
|
|
||
| # The debug macro configuration does not use Microsoft bit-field | ||
| # allocation, so its layouts do not match the code that MSVC generates. | ||
| - name: Configure windows-msvc-release | ||
| run: cmake --preset windows-msvc-release -DEDG_SELF_COMPILE=ON | ||
|
|
||
| - name: Build cpfe-self | ||
| run: cmake --build build/msvc-release --target cpfe-self | ||
|
|
||
| - name: Check cpfe-self | ||
| run: cmake --build build/msvc-release --target cpfe-self-check | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disable credential persistence in both checkouts.
Checkout v7 retains Git authentication by default until post-job cleanup. The subsequent configure and build steps execute PR-controlled code while that authentication remains accessible. Set
persist-credentials: falsein both checkout steps to remove this unnecessary exposure. (github.com)Based on learnings, use
persist-credentials: falsewhen building PR-controlled code, including onpull_request.Also applies to: 74-74
zizmor (1.32.0)
[warning] 52-53: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 14-95: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 23-62: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
Sources: Learnings, Linters/SAST tools