-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store global variables and function addresses as 32bit offsets #22472
Conversation
1b797c4
to
93a7578
Compare
@@ -1137,24 +1144,21 @@ void jl_dump_native(const char *bc_fname, const char *unopt_bc_fname, const char | |||
} | |||
} | |||
|
|||
ValueToValueMapTy VMap; | |||
Module *clone = shadow_output; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pass managers below aren't idempotent immutable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does that matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right nevermind; we've dropped support for versions of LLVM where jl_add_to_shadow
wasn't already making the clone.
Local test shows that the change has a subtle effect on symbol lookup on windows. Not having to reference them for dynamic relocation somehow removes it from whatever table This probably also means that we were just doing a closest match lookup for functions in the sysimg fvars so we can just get the old behavior back by just doing that. Any idea how to make force |
Just get rid of this chunk of code. It doesn't work right, but the replacement code path (using LLVM to read the symbol table) only started to be available recently in LLVM 3.5. |
93a7578
to
812707a
Compare
So I believe what's happening is that the first method used on 32bit and 64bit windows never worked as expected since they were only looking for exported function addresses and there was none before this PR. This PR exported one function as an alias so suddenly that broken method starts to return bad result and breaks the tests everywhere. I fixed this by fixing #17251 and #20798 by adding the method mentioned in #20798 (comment) (Thanks to @vtjnash for telling me that we are already using the necessary classes). Although I just realized that a simpler fix for the symptom is actually simply removing the broken method since it was never doing anything. Oh, well The broken test in |
The first commit should be backportable to 0.6 if anyone wants it. |
|
812707a
to
a9e60bb
Compare
yes and no. I never expected it to work (it was present for getting lookup of functions in ntdll and msvcrt correct), I just also didn't expect it to break the sysimg lookup. |
c5e9f41
to
fea7fd1
Compare
* Add a (slow but cross-platform) fallback lookup method of function name and base address using LLVM debug info reader * Disable windows exported symbol lookup that never worked for sysimg function address lookup (since they are never exported). Also move it after LLVM debug info reader since it is less accurate unless LLVM couldn't get any debug info. Fix #17251 Fix #20798
* Require small code model for sysimg * Makes the two tables static data and reduces the number of dynamic relocations by ~100x (~40k to ~400).
fea7fd1
to
92152aa
Compare
@@ -423,13 +423,7 @@ end | |||
for precomp in ("yes", "no") | |||
bt = readstring(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --precompiled=$precomp | |||
-E 'include("____nonexistent_file")'`), stderr=catcmd)) | |||
@test contains(bt, "include_from_node1") | |||
if ((is_windows() && Sys.WORD_SIZE == 32) || (is_bsd() && !is_apple())) && precomp == "yes" | |||
# FIXME: Issue #17251 (Windows), #20798 (FreeBSD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, thanks for fixing this
got following test error after this PR merged (https://julia.iblis.cnmc.tw/#/builders/2/builds/79):
|
The first one comes from 0737032 the version in The second one shows that it is still not fixed on freebsd, though the issue seems to be that the dladdr is messing it up. This agrees with the nonsense backtrace for the first issue. It is probably similar to the windows situation. Can you try if the cmdlineargs test pass on the first commit on this pr? If that fix the issue then I can probably tweak the order again so it's not broken by the second commit. |
Same failure as #22472 (comment) on all 5 buildbots in #22503 |
The problem isn't with this PR but with 0737032#commitcomment-22740108. Fix in #22506 |
@yuyichao I checkouted 8c658c5, and the
|
Oh, well, in that case someone else needs to figure out a fix for #20798 then. |
@yuyichao I just found another error I overlooked previously:
|
FYI: from line 246 https://julia.iblis.cnmc.tw/#/builders/2/builds/79/steps/5/logs/stdio |
That's probably the nonsense bt I mentioned above. |
For reference, julia> Base.compilecache("Baz")
INFO: Precompiling module Baz.
ERROR: LoadError: Declaring __precompile__(false) is not allowed in files that are being precompiled.
Stacktrace:
[1] @generated(::LineNumberNode, ::Module, ::ANY) at ./loading.jl:334
[2] @generated(::LineNumberNode, ::Module, ::ANY) at ./loading.jl:549
[3] @generated(::LineNumberNode, ::Module, ::ANY) at ./sysimg.jl:14
[4] anonymous at ./<missing>:2
while loading /usr/home/iblis/git/julia/tmp/Baz.jl, in expression starting on line 1
ERROR: Failed to precompile Baz to /home/iblis/.julia/lib/v0.7/Baz.ji.
Stacktrace:
[1] @generated(::LineNumberNode, ::Module, ::ANY) at ./loading.jl:689 On Linux: julia> Base.compilecache("Baz")
INFO: Precompiling module Baz.
ERROR: LoadError: Declaring __precompile__(false) is not allowed in files that are being precompiled.
Stacktrace:
[1] __precompile__(::Bool) at ./loading.jl:334
[2] include_from_node1(::Module, ::String) at ./loading.jl:549
[3] include(::Module, ::String) at ./sysimg.jl:14
[4] anonymous at ./<missing>:2
while loading /home/iblis/git/julia/tmp/Baz.jl, in expression starting on line 1
ERROR: Failed to precompile Baz to /home/iblis/.julia/lib/v0.7/Baz.ji.
Stacktrace:
[1] compilecache(::String) at ./loading.jl:689 The bt on FreeBSD become quite useless :/ |
were they any better before this pr? |
before this PR, it can reveal the exception was raised from julia> Base.compilecache("Baz")
INFO: Precompiling module Baz.
ERROR: LoadError: Declaring __precompile__(false) is not allowed in files that are being precompiled.
Stacktrace:
[1] __precompile__ at ./loading.jl:334
[2] include_from_node1 at ./loading.jl:549
[3] include at ./sysimg.jl:14
[4] anonymous at ./<missing>:2
while loading /usr/home/iblis/git/julia/tmp/Baz.jl, in expression starting on line 1
ERROR: Failed to precompile Baz to /home/iblis/.julia/lib/v0.7/Baz.ji.
Stacktrace:
[1] compilecache at ./loading.jl:689
julia> versioninfo()
Julia Version 0.7.0-DEV.679
Commit 02804aceef* (2017-06-23 01:13 UTC)
Platform Info:
OS: FreeBSD (x86_64-unknown-freebsd12.0)
CPU: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, westmere)
Environment: |
I just found this make bt work on FreeBSD but do not understand why diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp
index a2b3012f4a..6f8224c73a 100644
--- a/src/debuginfo.cpp
+++ b/src/debuginfo.cpp
@@ -729,6 +729,10 @@ static void get_function_name_and_base(const object::ObjectFile *object, bool in
{
if (!object)
return;
+#ifdef _OS_FREEBSD_
+ *name = nullptr;
+ *saddr = nullptr;
+#endif
// Assume we only need base address for sysimg for now
if (!insysimage || !sysimg_fvars_base)
saddr = nullptr; |
This is the ordering problem I mentioned. Doing it here is wrong but it seems that there's no way to do this correctly on freebsd. |
@yuyichao :-o . So... can we simply disable dladdr and rely on |
Not disabling it but try it later. |
Quote from FreeBSD
Do we hit the bug mentioned in manual?
Yes, I just observed that in gdb ( |
…n FreeBSD There is a known bug in FreeBSD's dladdr(3): (Quote from manual dladdr(3)) In dynamically linked programs, the address of a global function is considered to point to its program linkage table entry, rather than to the entry point of the function itself. This causes most global functions to appear to be defined within the main executable, rather than in the shared libraries where the actual code resides. Function `get_function_name_and_base` implemented in PR JuliaLang#22472 provides a (slow but cross-platform) way to lookup function name and base address via LLVM. @yuyichao propose that getting info from `get_function_name_and_base` first and making original `dladdr` as fallback. Fix: JuliaLang#20798 See also: JuliaLang#22472 (comment)
* Add a (slow but cross-platform) fallback lookup method of function name and base address using LLVM debug info reader * Disable windows exported symbol lookup that never worked for sysimg function address lookup (since they are never exported). Also move it after LLVM debug info reader since it is less accurate unless LLVM couldn't get any debug info. Fix #17251 Fix #20798 Ref #22472 (cherry picked from commit 8c658c5)
Yet another PR split out of #21849 ....
This makes the two tables static data and reduces the number of dynamic relocations by ~100x
(~40k to ~400). Before @JeffBezanson asks, this reduces the size of the
.rela.dyn
section from1144776
to9432
while other sections remains roughly the same. Total size reduction is ~1.25MB. Apparently each pointer takes ~32bytes.