tshort / StaticCompiler.jl

Compiles Julia code to a standalone library (experimental)
Other
488 stars 31 forks source link

Demangle #123

Closed brenhinkeller closed 1 year ago

brenhinkeller commented 1 year ago

This attempts to re-implement name demangling in a consistent way across all methods, plus a bit of general cleanup

There are some failures on Nightly that I'm not sure the deal with yet, will have to check if they are from this PR or not..

We could also think about whether we want to turn on demangling by default -- would arguably more convenient and logical long-term, though possibly technically a breaking change?

tshort commented 1 year ago

I'm fine with demangling by default.

brenhinkeller commented 1 year ago

Ok, looks like we have the same Nightly failures in https://github.com/tshort/StaticCompiler.jl/tree/rerun-ci (something to do with Nightly breaking LV / StrideArrays?) but I'll wait a day to see if it resolves itself

If folks are good with it, I'll plan to release this as 0.4.12 and then switch to demangling by default as 0.5.0 (and switch over StaticTools and examples to match)

brenhinkeller commented 1 year ago

For reference in case the logs disappear in the future, the failure on nightly here

     Testing Running tests...
WARNING: Method definition boundscheck() in module StrideArraysCore at /home/runner/.julia/packages/StrideArraysCore/Jn2h9/src/ptr_array.jl:889 overwritten at /home/runner/.julia/packages/StrideArraysCore/Jn2h9/src/StrideArraysCore.jl:72.
Basics: Error During Test at /home/runner/work/StaticCompiler.jl/StaticCompiler.jl/test/testcore.jl:6
  Got exception outside of a @test
  UndefVarError: `loop_unswitch!` not defined
  Stacktrace:
    [1] (::StaticCompiler.var"#14#15"{LLVM.Module, LLVM.TargetMachine})(pm::LLVM.ModulePassManager)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/optimize.jl:37
    [2] LLVM.ModulePassManager(::StaticCompiler.var"#14#15"{LLVM.Module, LLVM.TargetMachine}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}})
      @ LLVM ~/.julia/packages/LLVM/bsdku/src/passmanager.jl:33
    [3] LLVM.ModulePassManager(f::Function, args::Vararg{Any})
      @ LLVM ~/.julia/packages/LLVM/bsdku/src/passmanager.jl:30 [inlined]
    [4] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/optimize.jl:6 [inlined]
    [5] generate_obj_for_compile(f::StaticCompiler.var"#f_wrap!#22"{var"#simple_sum#5"}, tt::Type, external::Bool, path::String, name::String, filenamebase::String; mixtape::NoContext, strip_llvm::Bool, strip_asm::Bool, opt_level::Int64, remove_julia_addrspaces::Bool, target::Tuple{}, kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, @NamedTuple{filename::String}})
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:177
    [6] kwcall(::NamedTuple, ::typeof(StaticCompiler.generate_obj_for_compile), f::Any, tt::Any, external::Any, path::String, name::Any) (repeats 2 times)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:155 [inlined]
    [7] compile(f::var"#simple_sum#5", _tt::Tuple{DataType}, path::String; mixtape::NoContext, name::String, filename::String, strip_llvm::Bool, strip_asm::Bool, opt_level::Int64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}})
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:110
    [8] compile(f::Function, _tt::Tuple{DataType}, path::String)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:95
    [9] macro expansion
      @ ~/work/StaticCompiler.jl/StaticCompiler.jl/test/testcore.jl:12 [inlined]
   [10] macro expansion
      @ /opt/hostedtoolcache/julia/nightly/x64/share/julia/stdlib/v1.10/Test/src/Test.jl:1546 [inlined]
   [11] top-level scope
      @ ~/work/StaticCompiler.jl/StaticCompiler.jl/test/testcore.jl:8
   [12] include(fname::String)
      @ Base.MainInclude ./client.jl:478
   [13] top-level scope
      @ ~/work/StaticCompiler.jl/StaticCompiler.jl/test/runtests.jl:20
   [14] include(fname::String)
      @ Base.MainInclude ./client.jl:478
   [15] top-level scope
      @ none:6
   [16] eval(m::Module, e::Expr)
      @ Core ./boot.jl:383 [inlined]
   [17] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:280
   [18] _start()
      @ Base ./client.jl:541
Test Summary: | Error  Total   Time
Basics        |     1      1  24.5s

vs on main

     Testing Running tests...
WARNING: Method definition boundscheck() in module StrideArraysCore at /home/runner/.julia/packages/StrideArraysCore/Jn2h9/src/ptr_array.jl:889 overwritten at /home/runner/.julia/packages/StrideArraysCore/Jn2h9/src/StrideArraysCore.jl:72.
Basics: Error During Test at /home/runner/work/StaticCompiler.jl/StaticCompiler.jl/test/testcore.jl:3
  Got exception outside of a @test
  UndefVarError: `loop_unswitch!` not defined
  Stacktrace:
    [1] (::StaticCompiler.var"#14#15"{LLVM.Module, LLVM.TargetMachine})(pm::LLVM.ModulePassManager)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/optimize.jl:37
    [2] LLVM.ModulePassManager(::StaticCompiler.var"#14#15"{LLVM.Module, LLVM.TargetMachine}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}})
      @ LLVM ~/.julia/packages/LLVM/bsdku/src/passmanager.jl:33
    [3] LLVM.ModulePassManager(f::Function, args::Vararg{Any})
      @ LLVM ~/.julia/packages/LLVM/bsdku/src/passmanager.jl:30 [inlined]
    [4] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/optimize.jl:6 [inlined]
    [5] generate_obj_for_compile(f::StaticCompiler.var"#f_wrap!#22"{var"#simple_sum#5"}, tt::Type, external::Bool, path::String, name::String, filenamebase::String; mixtape::NoContext, strip_llvm::Bool, strip_asm::Bool, opt_level::Int64, remove_julia_addrspaces::Bool, target::Tuple{}, kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, @NamedTuple{filename::String}})
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:176
    [6] kwcall(::NamedTuple, ::typeof(StaticCompiler.generate_obj_for_compile), f::Any, tt::Any, external::Any, path::String, name::Any) (repeats 2 times)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:154 [inlined]
    [7] compile(f::var"#simple_sum#5", _tt::Tuple{DataType}, path::String; mixtape::NoContext, name::String, filename::String, strip_llvm::Bool, strip_asm::Bool, opt_level::Int64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}})
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:109
    [8] compile(f::Function, _tt::Tuple{DataType}, path::String)
      @ StaticCompiler ~/work/StaticCompiler.jl/StaticCompiler.jl/src/StaticCompiler.jl:94
    [9] macro expansion
      @ ~/work/StaticCompiler.jl/StaticCompiler.jl/test/testcore.jl:9 [inlined]
   [10] macro expansion
      @ /opt/hostedtoolcache/julia/nightly/x64/share/julia/stdlib/v1.10/Test/src/Test.jl:1546 [inlined]
   [11] top-level scope
      @ ~/work/StaticCompiler.jl/StaticCompiler.jl/test/testcore.jl:5
   [12] include(fname::String)
      @ Base.MainInclude ./client.jl:478
   [13] top-level scope
      @ ~/work/StaticCompiler.jl/StaticCompiler.jl/test/runtests.jl:20
   [14] include(fname::String)
      @ Base.MainInclude ./client.jl:478
   [15] top-level scope
      @ none:6
   [16] eval(m::Module, e::Expr)
      @ Core ./boot.jl:383 [inlined]
   [17] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:280
   [18] _start()
      @ Base ./client.jl:541
Test Summary: | Error  Total   Time
Basics        |     1      1  24.5s
ERROR: LoadError: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.