Skip to content
Merged
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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,29 @@ jobs:
- os: macos-latest
arch: aarch64
version: 'nightly'
- os: ubuntu-latest
arch: x86
version: '1'
- os: ubuntu-latest
arch: x86
version: 'pre'
- os: ubuntu-latest
arch: x86
version: 'nightly'
- os: windows-latest
arch: x86
version: '1'
steps:
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- name: Install 32-bit cross toolchain
if: ${{ runner.os == 'Linux' && matrix.arch == 'x86' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
Expand Down
2 changes: 1 addition & 1 deletion Artifacts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lazy = true

[[mingw-w64]]
arch = "i686"
git-tree-sha1 = "76b9f278e7de1d7dfdfe3a786afbe9c1e29003ea"
git-tree-sha1 = "85a99abd904b7d85813340fa459899f61fe2e9cc"
os = "windows"
lazy = true

Expand Down
5 changes: 3 additions & 2 deletions src/abi_export.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ function emit_struct_info!(ctx::TypeEmitter, @nospecialize(dt::DataType); indent
indented_println(" \"size\": ", Core.sizeof(dt), ",")
indented_println(" \"alignment\": ", Base.datatype_alignment(dt), ",")
indented_println(" \"fields\": [")
for i = 1:Base.datatype_nfields(dt)
nfields = Int(Base.datatype_nfields(dt))
for i = 1:nfields
emit_field_info!(ctx, dt, i; indent = indent + 4)
println(ctx.io, i == Base.datatype_nfields(dt) ? "" : ",")
println(ctx.io, i == nfields ? "" : ",")
end
indented_println(" ]")
print(ctx.io, " " ^ indent, "}")
Expand Down
18 changes: 18 additions & 0 deletions src/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,20 @@ function includeDir()
return abspath(Sys.BINDIR, Base.INCLUDEDIR, "julia")
end

function march_flags()
if Sys.ARCH === :i686
return "-m32 -march=pentium4"
end
return ""
end

function ldflags(; framework::Bool=false)
framework && return "-F$(shell_escape(frameworkDir()))"
fl = "-L$(shell_escape(libDir()))"
march = march_flags()
if !isempty(march)
fl = march * " " * fl
end
if Sys.iswindows()
fl = fl * " -Wl,--stack,8388608"
elseif !Sys.isapple()
Expand Down Expand Up @@ -89,6 +100,13 @@ end
function cflags(; framework::Bool=false)
flags = IOBuffer()
print(flags, "-std=gnu11")
march = march_flags()
if !isempty(march)
print(flags, " ", march)
end
if Sys.ARCH === :i686
print(flags, " -Wno-psabi")
end
if framework
include = shell_escape(frameworkDir())
print(flags, " -F", include)
Expand Down
6 changes: 6 additions & 0 deletions src/linking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ function link_products(recipe::LinkRecipe)
end
# Link in the whole archive and user-provided objects, then undo WHOLE_ARCHIVE
cmd2 = `$cmd2 -Wl,$(Base.Linking.WHOLE_ARCHIVE) $(image_recipe.img_path) $(image_recipe.extra_objects) -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
if Sys.ARCH === :i686
# On 32-bit x86, Julia's 64-bit atomics require libatomic
cmd2 = `$cmd2 -latomic`
# On 32-bit x86, float math (e.g. floorf) can become a libcall to libm
cmd2 = `$cmd2 -lm`
end
# Platform-specific linker flags
lib_name = basename(recipe.outname)
if Sys.iswindows()
Expand Down
8 changes: 4 additions & 4 deletions test/cli.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ end
CVector_Float32 = abi["types"][findfirst(type["name"] == "CVector{Float32}" for type in abi["types"])]
@test length(CVector_Float32["fields"]) == 2
@test CVector_Float32["fields"][1]["offset"] == 0
@test CVector_Float32["fields"][2]["offset"] == 8
@test CVector_Float32["fields"][2]["offset"] == sizeof(UInt)
@test abi["types"][CVector_Float32["fields"][1]["type_id"]]["name"] == "Int32"
@test abi["types"][CVector_Float32["fields"][2]["type_id"]]["name"] == "Ptr{Float32}"
@test CVector_Float32["size"] == 16
@test CVector_Float32["size"] == sizeof(UInt) * 2

# `CVectorPair{Float32}` should have been exported with the correct info
@test any(Bool[type["name"] == "CVectorPair{Float32}" for type in abi["types"]])
CVectorPair_Float32 = abi["types"][findfirst(type["name"] == "CVectorPair{Float32}" for type in abi["types"])]
@test length(CVectorPair_Float32["fields"]) == 2
@test CVectorPair_Float32["fields"][1]["offset"] == 0
@test CVectorPair_Float32["fields"][2]["offset"] == 16
@test CVectorPair_Float32["fields"][2]["offset"] == sizeof(UInt) * 2
@test abi["types"][CVectorPair_Float32["fields"][1]["type_id"]]["name"] == "CVector{Float32}"
@test abi["types"][CVectorPair_Float32["fields"][2]["type_id"]]["name"] == "CVector{Float32}"
@test CVectorPair_Float32["size"] == 32
@test CVectorPair_Float32["size"] == sizeof(UInt) * 4

# `CTree{Float64}` should have been exported with the correct info
@test any(Bool[type["name"] == "CTree{Float64}" for type in abi["types"]])
Expand Down
12 changes: 6 additions & 6 deletions test/programatic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
cc = something(Sys.which("cc"), Sys.which("clang"))
cc === nothing && error("C compiler not found")
if Sys.islinux()
run(`$cc -o $exe $csrc -ldl`)
run(`$cc $(cflags()) -o $exe $csrc -ldl`)
else
run(`$cc -o $exe $csrc`)
run(`$cc $(cflags()) -o $exe $csrc`)
end
run(`$exe $libpath`)
end
Expand Down Expand Up @@ -87,9 +87,9 @@
cc = something(Sys.which("cc"), Sys.which("clang"))
cc === nothing && error("C compiler not found")
if Sys.islinux()
run(`$cc -o $exe $csrc -ldl`)
run(`$cc $(cflags()) -o $exe $csrc -ldl`)
else
run(`$cc -o $exe $csrc`)
run(`$cc $(cflags()) -o $exe $csrc`)
end
run(`$exe $libpath`)
end
Expand Down Expand Up @@ -483,9 +483,9 @@ end
exe = joinpath(bindir, Sys.iswindows() ? "ctest_jloptions.exe" : "ctest_jloptions")
cc = JuliaC.get_compiler_cmd()
if Sys.islinux()
run(`$cc -o $exe $csrc -ldl`)
run(`$cc $(cflags()) -o $exe $csrc -ldl`)
else
run(`$cc -o $exe $csrc`)
run(`$cc $(cflags()) -o $exe $csrc`)
end

out = read(`$exe $libpath`, String)
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const TEST_SRC = joinpath(TEST_PROJ, "src", "test.jl")
const TEST_LIB_PROJ = abspath(joinpath(@__DIR__, "lib_project"))
const TEST_LIB_SRC = joinpath(TEST_LIB_PROJ, "src", "libtest.jl")

include("utils.jl")

include("programatic.jl")
include("cli.jl")
include("trimming.jl")
Expand Down
4 changes: 2 additions & 2 deletions test/trimming.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ end
cc = JuliaC.get_compiler_cmd()

if Sys.islinux()
run(`$cc -o $exe $csrc -ldl`)
run(`$cc $(cflags()) -o $exe $csrc -ldl`)
else
run(`$cc -o $exe $csrc`)
run(`$cc $(cflags()) -o $exe $csrc`)
end

# Run the C application
Expand Down
1 change: 1 addition & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cflags() = Base.shell_split(JuliaC.JuliaConfig.march_flags())