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

Add Emscripten branch to arc4random #1061

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
716c5df
Add Emscripten branch to arc4random
MoustaphaSaad May 28, 2024
a3e7866
disable explicit_bzero because of lack of sigsuspend support on Emscr…
MoustaphaSaad May 31, 2024
07bb080
replace add_test with add_platform_test
MoustaphaSaad May 31, 2024
3ef2b99
fix aeadtest
MoustaphaSaad May 31, 2024
068d975
disable arc4randomforktest because Emscripten lacks fork support
MoustaphaSaad May 31, 2024
e1a5577
fix apitest
MoustaphaSaad May 31, 2024
1a89b8b
fix bn_unit
MoustaphaSaad May 31, 2024
5dc7b08
fix cttest
MoustaphaSaad May 31, 2024
9ce914a
fix evptest
MoustaphaSaad May 31, 2024
91c9240
fix keypairtest
MoustaphaSaad May 31, 2024
d68e1f3
fix policy
MoustaphaSaad May 31, 2024
68253e9
fix pq_test
MoustaphaSaad May 31, 2024
2d10616
fix quictest
MoustaphaSaad May 31, 2024
3384d0d
fix servertest
MoustaphaSaad May 31, 2024
f8f9f4c
fix shutdowntest
MoustaphaSaad May 31, 2024
1c288fd
fix ssl_get_shared_ciphers
MoustaphaSaad May 31, 2024
0da126f
fix ssltest
MoustaphaSaad May 31, 2024
e8ddeb2
disable testdsa
MoustaphaSaad May 31, 2024
cfba8c8
disable testenc
MoustaphaSaad May 31, 2024
86a9833
disable testrsa
MoustaphaSaad May 31, 2024
8b407f0
disable tlstest
MoustaphaSaad May 31, 2024
b5a473b
add initial Emscripten CI workflow
MoustaphaSaad May 31, 2024
698cbd5
wrap bn_unit ALLOW_MEMORY_GROWTH in if(EMSCRIPTEN)
MoustaphaSaad Jun 1, 2024
51258d4
use emcmake instead of feeding toolchain file manually
MoustaphaSaad Jun 4, 2024
469e536
simplify explicit_bzero comment
MoustaphaSaad Jun 7, 2024
396d904
fix emscripten.yml workflow
MoustaphaSaad Jun 7, 2024
da2b1d7
replace if(EMSCRIPTEN) with prepare_emscripten_test_target function
MoustaphaSaad Jun 7, 2024
bca4cca
use -gsource-map instead of -ggdb
MoustaphaSaad Jun 7, 2024
fec43f2
group testdsa, testenc, and testrsa under a single if(NOT EMSCRIPTEN)
MoustaphaSaad Jun 7, 2024
467a4b8
call prepare_emscripten_test_target for x509_asn1 to fix an OOM error
MoustaphaSaad Jun 7, 2024
8a22796
use compat implementations of strlcpy and strlcat
MoustaphaSaad Jun 10, 2024
df07598
Fix comment in emscripten.yml
MoustaphaSaad Jun 16, 2024
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
71 changes: 71 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# GitHub Actions workflow to run tests on Linux.
MoustaphaSaad marked this conversation as resolved.
Show resolved Hide resolved
name: "Emscripten"

on:
push: {}
pull_request: {}
schedule:
- cron: "0 0 * * *" # At 00:00 daily.

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
test:
name: "Emscripten"
runs-on: "ubuntu-latest"
if: ${{ github.repository_owner == 'libressl' || github.event_name != 'schedule' }}
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup emsdk"
uses: mymindstorm/setup-emsdk@v14
with:
version: "3.1.60"

- name: "Prepare repository"
run: ./autogen.sh

- name: "Configure CMake"
run: emcmake cmake -Bbuild

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to run fine locally with the latest emsdk. Is it more typical to build as you've done in the github actions by setting the toolchain parameters manually, or use wrappers like emcmake / emconfigure like below? It doesn't seem to be necessary to manually disable ASM either - we probably shouldn't require a switch if this is the proper default for the platform.

$ emcmake cmake .. -GNinja
configure: cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=/home/bcook/projects/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/home/bcook/projects/emsdk/node/18.20.3_64bit/bin/node
-- The ASM compiler identification is unknown
-- Found assembler: /home/bcook/projects/emsdk/upstream/emscripten/emcc
-- Warning: Did not find file Compiler/-ASM
-- Setting build type to 'Release' as none was specified.
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, using emcmake is the recommended way in Emscripten website, I'll change it to use it instead of feeding it the toolchain file manually

- name: "Build"
run: cmake --build build --config Release

- name: "Test"
run: ctest --test-dir build -C Release --output-on-failure

# Test ASAN with and without ASM enabled.
test-asan:
joshuasing marked this conversation as resolved.
Show resolved Hide resolved
name: "ASAN (no-asm)"
runs-on: "ubuntu-latest"
if: ${{ github.repository_owner == 'libressl' || github.event_name != 'schedule' }}
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup emsdk"
uses: mymindstorm/setup-emsdk@v14
with:
version: "3.1.60"

- name: "Prepare repository"
run: ./autogen.sh

- name: "Configure CMake"
run: emcmake cmake -Bbuild
env:
CFLAGS: "-gsource-map -fsanitize=address"
LDFLAGS: "-fsanitize=address"

- name: "Build"
run: cmake --build build --config Release

- name: "Test"
run: ctest --test-dir build -C Release --output-on-failure
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,17 @@ if(HAVE_STRCASECMP)
add_definitions(-DHAVE_STRCASECMP)
endif()

check_function_exists(strlcat HAVE_STRLCAT)
if(HAVE_STRLCAT)
add_definitions(-DHAVE_STRLCAT)
endif()
# Emscripten's strlcat and strlcpy triggers ASAN errors
if(NOT EMSCRIPTEN)
check_function_exists(strlcat HAVE_STRLCAT)
if(HAVE_STRLCAT)
add_definitions(-DHAVE_STRLCAT)
endif()

check_function_exists(strlcpy HAVE_STRLCPY)
if(HAVE_STRLCPY)
add_definitions(-DHAVE_STRLCPY)
check_function_exists(strlcpy HAVE_STRLCPY)
if(HAVE_STRLCPY)
add_definitions(-DHAVE_STRLCPY)
endif()
endif()

check_function_exists(strndup HAVE_STRNDUP)
Expand Down
3 changes: 3 additions & 0 deletions crypto/compat/arc4random.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#elif defined(_WIN32)
#include "arc4random_win.h"

#elif defined(__EMSCRIPTEN__)
#include "arc4random_linux.h"

#else
#error "No arc4random hooks defined for this platform."

Expand Down
Loading
Loading