Skip to content

Commit

Permalink
Merge pull request #399 from moonbitlang/lm
Browse files Browse the repository at this point in the history
internal: add -lm for unix native --release
  • Loading branch information
Young-Flash authored Oct 17, 2024
2 parents 502834a + 933113b commit f26c717
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/bleeding-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# For inquiries, you can contact us via e-mail at [email protected].

name: Bleeding Release Unix
name: Bleeding Release

# trigger by moonc-version-dont-delete/.github/workflows/ci.yml when moonc merged PR

Expand Down Expand Up @@ -70,8 +70,6 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
shell: pwsh
run: |
$PLATFORM = "windows-x86_64"
echo "PLATFORM=$PLATFORM" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Remove-Item -Recurse -Force tmp-bins -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path tmp-bins
Invoke-WebRequest -Uri "https://cli.moonbitlang.com/moon-ci/Windows-x86_64.zip" -OutFile moonbit.zip
Expand All @@ -80,9 +78,9 @@ jobs:
Copy-Item .\target\release\moon.exe .\tmp-bins
Get-ChildItem .\tmp-bins
Push-Location tmp-bins
Get-FileHash -Algorithm SHA256 * | ForEach-Object { $_.Hash + " " + $_.Path.Split("\")[-1] } | Out-File -FilePath ..\moonbit-$env:PLATFORM.sha256 -Encoding utf8
Get-FileHash -Algorithm SHA256 * | ForEach-Object { $_.Hash + " " + $_.Path.Split("\")[-1] } | Out-File -FilePath ..\moonbit-windows-x86_64.sha256 -Encoding utf8
Pop-Location
Compress-Archive -Path .\tmp-bins\* -DestinationPath .\moonbit-$env:PLATFORM.zip
aws s3 cp .\moonbit-$env:PLATFORM.zip s3://cli.moonbitlang.com/binaries/bleeding/moonbit-$env:PLATFORM.zip
aws s3 cp .\moonbit-$env:PLATFORM.sha256 s3://cli.moonbitlang.com/binaries/bleeding/moonbit-$env:PLATFORM.sha256
Compress-Archive -Path .\tmp-bins\* -DestinationPath .\moonbit-windows-x86_64.zip
aws s3 cp .\moonbit-windows-x86_64.zip s3://cli.moonbitlang.com/binaries/bleeding/moonbit-windows-x86_64.zip
aws s3 cp .\moonbit-windows-x86_64.sha256 s3://cli.moonbitlang.com/binaries/bleeding/moonbit-windows-x86_64.sha256
aws cloudfront create-invalidation --distribution-id E1KQYZEVEB0TAY --paths "/*"
2 changes: 1 addition & 1 deletion crates/moon/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub fn get_compiler_flags(
// use "cc" to compile
extra_link_opt.extend_from_slice(&[
"-cc".to_string(),
format!("cc {} -O2 -fwrapv", libmoonbitrun_path.display()),
format!("cc {} -O2 -fwrapv -lm", libmoonbitrun_path.display()),
]);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7072,7 +7072,7 @@ fn test_use_cc_for_native_release() {
expect![[r#"
moonc build-package ./lib/hello.mbt -o ./target/native/release/build/lib/lib.core -pkg moonbitlang/hello/lib -std-path $MOON_HOME/lib/core/target/native/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target native
moonc build-package ./main/main.mbt -o ./target/native/release/build/main/main.core -pkg moonbitlang/hello/main -is-main -std-path $MOON_HOME/lib/core/target/native/release/bundle -i ./target/native/release/build/lib/lib.mi:lib -pkg-sources moonbitlang/hello/main:./main -target native
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/build/lib/lib.core ./target/native/release/build/main/main.core -main moonbitlang/hello/main -o ./target/native/release/build/main/main.exe -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv"
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/build/lib/lib.core ./target/native/release/build/main/main.core -main moonbitlang/hello/main -o ./target/native/release/build/main/main.exe -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv -lm"
"#]],
);
// if --release is not specified, it should not use cc
Expand Down Expand Up @@ -7125,7 +7125,7 @@ fn test_use_cc_for_native_release() {
expect![[r#"
moonc build-package ./lib/hello.mbt -o ./target/native/release/build/lib/lib.core -pkg moonbitlang/hello/lib -std-path $MOON_HOME/lib/core/target/native/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target native
moonc build-package ./main/main.mbt -o ./target/native/release/build/main/main.core -pkg moonbitlang/hello/main -is-main -std-path $MOON_HOME/lib/core/target/native/release/bundle -i ./target/native/release/build/lib/lib.mi:lib -pkg-sources moonbitlang/hello/main:./main -target native
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/build/lib/lib.core ./target/native/release/build/main/main.core -main moonbitlang/hello/main -o ./target/native/release/build/main/main.exe -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv"
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/build/lib/lib.core ./target/native/release/build/main/main.core -main moonbitlang/hello/main -o ./target/native/release/build/main/main.exe -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv -lm"
./target/native/release/build/main/main.exe
"#]],
);
Expand Down Expand Up @@ -7188,10 +7188,10 @@ fn test_use_cc_for_native_release() {
expect![[r#"
moon generate-test-driver --source-dir . --target-dir ./target/native/release/test --package moonbitlang/hello/lib --sort-input --target native --driver-kind whitebox
moonc build-package ./lib/hello.mbt ./lib/hello_wbtest.mbt ./target/native/release/test/lib/__generated_driver_for_whitebox_test.mbt -o ./target/native/release/test/lib/lib.whitebox_test.core -pkg moonbitlang/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/native/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target native
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/test/lib/lib.whitebox_test.core -main moonbitlang/hello/lib -o ./target/native/release/test/lib/lib.whitebox_test.exe -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -exported_functions moonbit_test_driver_internal_execute -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv"
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/test/lib/lib.whitebox_test.core -main moonbitlang/hello/lib -o ./target/native/release/test/lib/lib.whitebox_test.exe -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -exported_functions moonbit_test_driver_internal_execute -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv -lm"
moon generate-test-driver --source-dir . --target-dir ./target/native/release/test --package moonbitlang/hello/lib --sort-input --target native --driver-kind internal
moonc build-package ./lib/hello.mbt ./target/native/release/test/lib/__generated_driver_for_internal_test.mbt -o ./target/native/release/test/lib/lib.internal_test.core -pkg moonbitlang/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/native/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target native
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/test/lib/lib.internal_test.core -main moonbitlang/hello/lib -o ./target/native/release/test/lib/lib.internal_test.exe -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -exported_functions moonbit_test_driver_internal_execute -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv"
moonc link-core $MOON_HOME/lib/core/target/native/release/bundle/core.core ./target/native/release/test/lib/lib.internal_test.core -main moonbitlang/hello/lib -o ./target/native/release/test/lib/lib.internal_test.exe -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -exported_functions moonbit_test_driver_internal_execute -target native -cc "cc $MOON_HOME/bin/libmoonbitrun.o -O2 -fwrapv -lm"
"#]],
);
check(
Expand Down

0 comments on commit f26c717

Please sign in to comment.