Skip to content

Commit 08cfa39

Browse files
committed
Merge pull request atomvm#2075 from pguyot/w05/workaround-esp32-elixirc-build-failure
Handle elixirc parallel compilation Ensure that modules are not partially written when elixirc tries to access them by compiling modules to a temporary directory and moving them to the beams directory next. This fixes one of the esp32 flappiness as it could fail on CI with ninja. Also convert FreeBSD builds to ninja to workaround the weird truncation issue we are having with make builds. These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents dbc1540 + f4823c2 commit 08cfa39

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.github/workflows/build-and-test-on-freebsd.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: "Install deps"
6464
shell: freebsd {0}
6565
run: |
66-
pkg install -y curl cmake gperf erlang elixir rebar3 mbedtls3
66+
pkg install -y curl cmake gperf erlang elixir rebar3 mbedtls3 ninja
6767
6868
- name: "Add hostname to /etc/hosts for distribution tests"
6969
shell: freebsd {0}
@@ -108,19 +108,19 @@ jobs:
108108
cd build
109109
cmake .. -DMBEDTLS_ROOT_DIR=/usr/local -DAVM_WARNINGS_ARE_ERRORS=ON
110110
111-
- name: "Build: run make"
111+
- name: "Build: compile"
112112
shell: freebsd {0}
113113
run: |
114114
cd $GITHUB_WORKSPACE;
115115
cd build
116-
make -j `sysctl -n hw.ncpu`
116+
cmake --build .
117117
118118
- name: "Build: run dialyzer"
119119
shell: freebsd {0}
120120
run: |
121121
cd $GITHUB_WORKSPACE;
122122
cd build
123-
make -j `sysctl -n hw.ncpu`
123+
cmake --build . -t dialyzer
124124
125125
- name: "Test: test-erlang"
126126
shell: freebsd {0}
@@ -197,7 +197,7 @@ jobs:
197197
run: |
198198
cd $GITHUB_WORKSPACE;
199199
cd build
200-
make install
200+
cmake --build . -t install
201201
atomvm examples/erlang/hello_world.avm
202202
atomvm -v
203203
atomvm -h

CMakeModules/BuildElixir.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ macro(pack_archive avm_name)
2424
foreach(module_name ${ARGN})
2525
add_custom_command(
2626
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/beams/Elixir.${module_name}.beam
27-
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/beams && elixirc --no-docs --no-debug-info --ignore-module-conflict -o ${CMAKE_CURRENT_BINARY_DIR}/beams ${CMAKE_CURRENT_SOURCE_DIR}/${module_name}.ex
27+
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/beams ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.${module_name}
28+
COMMAND elixirc --no-docs --no-debug-info --ignore-module-conflict -o ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.${module_name}/ ${CMAKE_CURRENT_SOURCE_DIR}/${module_name}.ex
29+
COMMAND sh -c "mv ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.${module_name}/Elixir.*.beam ${CMAKE_CURRENT_BINARY_DIR}/beams/"
30+
COMMAND rmdir ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.${module_name}
2831
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${module_name}.ex
2932
COMMENT "Compiling ${module_name}.ex"
3033
VERBATIM

0 commit comments

Comments
 (0)