Skip to content

Commit 229863a

Browse files
committed
Set demangle=true by default
1 parent a571cb1 commit 229863a

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

src/StaticCompiler.jl

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ end
121121
generate_obj_for_compile(f, tt, path::String = tempname(), name = fix_name(f), filenamebase::String="obj";
122122
\tmixtape = NoContext(),
123123
\tstrip_llvm = false,
124-
\tstrip_asm = true,
124+
\tstrip_asm = true,
125125
\ttarget = (),
126-
\topt_level=3,
126+
\topt_level = 3,
127127
\tkwargs...)
128128
```
129129
Low level interface for compiling object code (`.o`) for for function `f` given
@@ -155,7 +155,7 @@ shell> tree \$path
155155
function generate_obj_for_compile(f, tt, external = true, path::String = tempname(), name = fix_name(f), filenamebase::String="obj";
156156
mixtape = NoContext(),
157157
strip_llvm = false,
158-
strip_asm = true,
158+
strip_asm = true,
159159
opt_level = 3,
160160
remove_julia_addrspaces = false,
161161
target = (),
@@ -271,9 +271,9 @@ function compile_executable(f::Function, types=(), path::String="./", name=fix_n
271271
end
272272

273273
function compile_executable(funcs::Union{Array,Tuple}, path::String="./", name=fix_name(first(first(funcs)));
274-
filename=name,
275-
demangle=false,
276-
cflags=``,
274+
filename = name,
275+
demangle = true,
276+
cflags = ``,
277277
kwargs...
278278
)
279279

@@ -294,14 +294,11 @@ end
294294
"""
295295
```julia
296296
compile_shlib(f::Function, types::Tuple, [path::String="./"], [name::String=repr(f)]; filename::String=name, cflags=``, kwargs...)
297-
compile_shlib(funcs::Array, [path::String="./"]; filename="libfoo", demangle=false, cflags=``, kwargs...)
297+
compile_shlib(funcs::Array, [path::String="./"]; filename="libfoo", demangle=true, cflags=``, kwargs...)
298298
```
299299
As `compile_executable`, but compiling to a standalone `.dylib`/`.so` shared library.
300300
301-
The compiled function is by default given the symbol name `julia_$(name)`, i.e.,
302-
the function `test` in the example below is called `julia_test` in the shared library.
303-
The keword argument `demangle=true` will remove this prefix, but is currently only
304-
supported the second (multi-function-shlib) method.
301+
If `demangle` is set to `false`, compiled function names are prepended with "julia_".
305302
306303
### Examples
307304
```julia
@@ -322,7 +319,7 @@ julia> compile_shlib(test, (Int,))
322319
julia> test(100_000)
323320
5.2564961094956075
324321
325-
julia> ccall(("julia_test", "test.dylib"), Float64, (Int64,), 100_000)
322+
julia> ccall(("test", "test.dylib"), Float64, (Int64,), 100_000)
326323
5.2564961094956075
327324
```
328325
"""
@@ -334,9 +331,9 @@ function compile_shlib(f::Function, types=(), path::String="./", name=fix_name(f
334331
end
335332
# As above, but taking an array of functions and returning a single shlib
336333
function compile_shlib(funcs::Union{Array,Tuple}, path::String="./";
337-
filename="libfoo",
338-
demangle=false,
339-
cflags=``,
334+
filename = "libfoo",
335+
demangle = true,
336+
cflags = ``,
340337
kwargs...
341338
)
342339
for func in funcs
@@ -358,20 +355,17 @@ end
358355
"""
359356
```julia
360357
compile_wasm(f::Function, types::Tuple, [path::String="./"], [name::String=repr(f)]; filename::String=name, flags=``, kwargs...)
361-
compile_wasm(funcs::Union{Array,Tuple}, [path::String="./"]; filename="libfoo", demangle=false, flags=``, kwargs...)
358+
compile_wasm(funcs::Union{Array,Tuple}, [path::String="./"]; filename="libfoo", demangle=true, flags=``, kwargs...)
362359
```
363360
As `compile_shlib`, but compiling to a WebAssembly library.
364361
365-
The compiled function is by default given the symbol name `julia_$(name)`, i.e.,
366-
the function `test` in the example below is called `julia_test` in the shared library.
367-
The keword argument `demangle=true` will remove this prefix, but is currently only
368-
supported the second (multi-function-shlib) method.
362+
If `demangle` is set to `false`, compiled function names are prepended with "julia_".
369363
```
370364
"""
371365
function compile_wasm(f::Function, types=();
372-
path::String="./",
373-
filename=fix_name(f),
374-
flags=``,
366+
path::String = "./",
367+
filename = fix_name(f),
368+
flags = ``,
375369
kwargs...
376370
)
377371
tt = Base.to_tuple_type(types)
@@ -471,8 +465,8 @@ Hello, world!
471465
"""
472466
generate_executable(f, tt, args...; kwargs...) = generate_executable(((f, tt),), args...; kwargs...)
473467
function generate_executable(funcs::Union{Array,Tuple}, path=tempname(), name=fix_name(first(first(funcs))), filename=name;
474-
demangle=false,
475-
cflags=``,
468+
demangle = true,
469+
cflags = ``,
476470
kwargs...
477471
)
478472
lib_path = joinpath(path, "$filename.$(Libdl.dlext)")
@@ -511,12 +505,14 @@ end
511505
"""
512506
```julia
513507
generate_shlib(f::Function, tt, [external::Bool=true], [path::String], [name], [filename]; kwargs...)
514-
generate_shlib(funcs::Array, [external::Bool=true], [path::String], [filename::String]; demangle=false, kwargs...)
508+
generate_shlib(funcs::Array, [external::Bool=true], [path::String], [filename::String]; demangle=true, kwargs...)
515509
```
516510
Low level interface for compiling a shared object / dynamically loaded library
517511
(`.so` / `.dylib`) for function `f` given a tuple type `tt` characterizing
518512
the types of the arguments for which the function will be compiled.
519513
514+
If `demangle` is set to `false`, compiled function names are prepended with "julia_".
515+
520516
### Examples
521517
```julia
522518
julia> using StaticCompiler, LoopVectorization
@@ -542,7 +538,7 @@ shell> tree \$path
542538
julia> test(100_000)
543539
5.2564961094956075
544540
545-
julia> ccall(("julia_test", "example/test.dylib"), Float64, (Int64,), 100_000)
541+
julia> ccall(("test", "example/test.dylib"), Float64, (Int64,), 100_000)
546542
5.2564961094956075
547543
```
548544
"""
@@ -551,8 +547,8 @@ function generate_shlib(f::Function, tt, external::Bool=true, path::String=tempn
551547
end
552548
# As above, but taking an array of functions and returning a single shlib
553549
function generate_shlib(funcs::Union{Array,Tuple}, external::Bool=true, path::String=tempname(), filename::String="libfoo";
554-
demangle=false,
555-
cflags=``,
550+
demangle = true,
551+
cflags = ``,
556552
kwargs...
557553
)
558554

@@ -595,7 +591,7 @@ function native_llvm_module(f, tt, name=fix_name(f); demangle, kwargs...)
595591
end
596592

597593
#Return an LLVM module for multiple functions
598-
function native_llvm_module(funcs::Union{Array,Tuple}; demangle=false, kwargs...)
594+
function native_llvm_module(funcs::Union{Array,Tuple}; demangle=true, kwargs...)
599595
f,tt = funcs[1]
600596
mod = native_llvm_module(f,tt; demangle, kwargs...)
601597
if length(funcs) > 1
@@ -635,10 +631,10 @@ end
635631
generate_obj(f, tt, external::Bool, path::String = tempname(), filenamebase::String="obj";
636632
mixtape = NoContext(),
637633
target = (),
638-
demangle =false,
634+
demangle = true,
639635
strip_llvm = false,
640636
strip_asm = true,
641-
opt_level=3,
637+
opt_level = 3,
642638
kwargs...)
643639
```
644640
Low level interface for compiling object code (`.o`) for for function `f` given
@@ -652,6 +648,8 @@ function will be compiled.
652648
This is a named tuple with fields `triple`, `cpu`, and `features` (each of these are strings).
653649
The defaults compile to the native target.
654650
651+
If `demangle` is set to `false`, compiled function names are prepended with "julia_".
652+
655653
### Examples
656654
```julia
657655
julia> fib(n) = n <= 1 ? n : fib(n - 1) + fib(n - 2)
@@ -695,7 +693,7 @@ This is a named tuple with fields `triple`, `cpu`, and `features` (each of these
695693
The defaults compile to the native target.
696694
"""
697695
function generate_obj(funcs::Union{Array,Tuple}, external::Bool, path::String = tempname(), filenamebase::String="obj";
698-
demangle = false,
696+
demangle = true,
699697
strip_llvm = false,
700698
strip_asm = true,
701699
opt_level = 3,

0 commit comments

Comments
 (0)