Skip to content
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

ingle -> single #1

Open
wants to merge 15 commits into
base: static-executable-v2
Choose a base branch
from
Open

ingle -> single #1

wants to merge 15 commits into from

Conversation

Uthar
Copy link

@Uthar Uthar commented Apr 14, 2021

No description provided.

daewok and others added 15 commits March 16, 2021 09:59
Add a new C function - arch_read_linkage_entry - that backs out the true
foreign address of the corresponding symbol from the data in the linkage table.

Add a Lisp function - FIND-LINKAGE-TABLE-FOREIGN-SYMBOL-ADDRESS - that uses
this new C function to return the address, while accounting for undefined
symbols (so as to not accidentally return a reference to a guard page).
If we can't get a runtime handle, we can't be sure that
FIND-DYNAMIC-FOREIGN-SYMBOL-ADDRESS will work, so teach
FIND-FOREIGN-SYMBOL-ADDRESS to look up symbols via dlsym or by backing out the
address from the linkage table. Replace most calls to
FIND-DYNAMIC-FOREIGN-SYMBOL-ADDRESS with FIND-FOREIGN-SYMBOL-ADDRESS.

This gets us a step closer to having #-os-provides-dlopen work.

Additionally, this lets us create a static executable with musl libc. Musl's
libdl functions all return an error when called within a static executable. At
the moment, the only way to take advantage of this is shrinkwrapping, as a
working libdl is required to build a working Lisp core from scratch.
Additionally, remove the comment fro the comma variable definition. On at least
GNU make 4.3, the value is set to ", ", not ",".
Move the linkage table filling for shrinkwrapped executables into its own
function.
Patch originally by Manuel Giraud <[email protected]>, I just cleaned up
some comments.
This is an internal feature. When present, genesis writes a C helper
file (linkage-table-prelink-info.c) that populates the C var
lisp_linkage_values. This variable (originally introduced as part of the
shrinkwrapping support) contains the true addresses of each variable and
function in the linkage table.

Then, when the runtime boots instead of using os_dlsym_default and
required-foreign-symbols to fill the linkage table, the data in
lisp_linkage_values is used instead. This has the affect of using the system
linker to prelink the entire linkage table instead of doing it ourselves.

Last, when the core boots, it has to fixup the prelinked entries. This is
required to make sure the linkage table points to the appropriate guards for
undefined foreign variables or functions. This cannot be done in the runtime
because some on some archs the undefined alien function guard is an assembly
routine generated in lisp. Instead, a NULL entry in lisp_linkage_values
indicates an undefined entry.

A useful feature for some use cases is to add extra symbols to the linkage
table at build time that we know we'll need at run time. This is accomplished
by passing the extra entries to the make process using the
--extra-linkage-table-entries argument.

The file must contain a single list. Each element is a linkage table entry
consisting of three elements. The first is a string naming the C symbol. The
second is T if the symbol is a variable, NIL if it is a function. The third is
T if the entry is undefined (this is currently pointless, but will become
useful in a future commit).

Enabling this feature on Windows causes a test failure. The root cause is that
mingw-w64 implements its trig functions as thin wrappers around fsin and
friends. This can be wildly inaccurate. When this feature is enabled, the trig
functions come from wingw-w64's libm. When this feature is disabled, the more
accurate trig functions from the Windows C runtime are used. See
https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/6141957e.8c6be.157053d0e19.Coremail.lh_mouse%40126.com/#msg35353216
and https://mingwpy.github.io/issues.html#math-precision-issues for more
details.
-os-provides-dlopen and -sb-prelink-linkage-table is incompatible.

In order to build a working core with -os-provides-dlopen you must provide the
list of all C symbols introduced in make-target-2.
@daewok daewok force-pushed the static-executable-v2 branch from 13032a9 to 20f2a97 Compare May 25, 2021 02:14
@daewok daewok force-pushed the static-executable-v2 branch from 20f2a97 to f6f8e19 Compare June 2, 2021 20:46
daewok pushed a commit that referenced this pull request Aug 31, 2021
The cases which zeroize the result due to oversized constant shift should
not care where the input operand is. Also, zeroize will accepts stack TNs.
So remember rule #1 of writing a :LOAD-IF, namely: it's always wrong.
@daewok daewok force-pushed the static-executable-v2 branch from f6f8e19 to 52f4fa7 Compare August 31, 2021 01:59
@daewok daewok force-pushed the static-executable-v2 branch from 52f4fa7 to bde302a Compare September 28, 2021 13:41
@daewok daewok force-pushed the static-executable-v2 branch from 453fd67 to b984fc9 Compare October 29, 2021 18:45
@daewok daewok force-pushed the static-executable-v2 branch from b984fc9 to d5d3197 Compare December 1, 2021 02:44
@daewok daewok force-pushed the static-executable-v2 branch from d5d3197 to cf15118 Compare January 3, 2022 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants