Repository navigation
Fpc linux x64 - #324
Open
dkounal wants to merge 8 commits into
Open
Fpc linux x64#324dkounal wants to merge 8 commits into
dkounal wants to merge 8 commits into
Conversation
Dec/Inc on a Variant lvalue is not accepted by FPC. ResultAsRegister is declared in the interface, but its body sat inside the part skipped by empty_methods_handler, so it moved in front of that part.
With FPC_UNICODE, string is UnicodeString but the Delphi version defines stayed off, so PChar and char based parser code read bytes as wide chars. TPSPluginItem.GetDisplayName follows the FCL ancestor, which stays AnsiString.
Extended goes on the stack, 16 bytes aligned, and comes back in ST0. Currency comes back in ST0 as a scaled integer. A dynamic array by value is the array, not the address of the variable. Records up to 16 bytes travel in registers according to the class of each eightbyte, and come back in RAX, RDX, XMM0 and XMM1. Each case was checked against the code FPC generates.
MyAllMethodsHandler was empty on FPC x86_64, so GetProcAsMethod gave a method that did nothing. New assembler stub and handler for Unix. Win64 and the other targets are not touched.
On System V a record above 16 bytes goes on the stack by value, but by reference when const. The compiler now records const: remobjects#2 in ImportDecl, & in the export declaration. Consumers that only compare with #0 or read the type number treat them as by value, as before.
uPSUtils.IntToStr shadows SysUtils.IntToStr in units that use it after SysUtils, and silently dropped the upper 32 bits.
Scripts ended in TObject.Create, so TStrings.Create never ran and Text lost its trailing line break.
Console runner without LCL, and tests for every parameter and result type in both call directions on x86_64 Linux. Enables the method handler tests there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FreePascal on Linux x86_64: fix the build, the System V calling code and add a method handler
Summary
On FPC x86_64 Linux the library did not compile,
GetProcAsMethodreturned a method that did nothing, and several script-to-native calls passed wrong values. This branch fixes all three and adds tests. Win64 code paths are unchanged.Changes
ResultAsRegistermoves out of the block skipped byempty_methods_handler.FPC_UNICODE: the switch inPascalScriptFPC.incnow builds and works.stringin scripts isUnicodeString, the same as on Delphi.Extendedgoes on the stack, 16 bytes aligned, and returns in ST0.Currencyreturns in ST0 as a scaled integer, not in RAX.MyAllMethodsHandleris implemented for x86_64 Unix (x64sysvhandler.inc).const: the compiler now keeps it, because a record above 16 bytes is passed by reference whenconstand on the stack otherwise. It is#2inImportDecland&in the export declaration.IntToStr:uPSUtils.IntToStrtakesInt64. It shadowsSysUtils.IntToStrand silently dropped the upper 32 bits.TStrings/TStringList: the constructors are registered on FPC too. Scripts ended inTObject.Create, soTStrings.Createnever ran andTextlost its trailing line break.dunit/fpcconsole.lpris a console runner without LCL.dunit/CompilerTestSysV.pascovers parameter and result types in both call directions.Each ABI case was checked against the assembly FPC generates.
Testing
-Mdelphifpcconsole: 33/33-Mdelphiunicode -dFPC_UNICODEfpcconsole: 33/33The DUnit project was not run on Delphi. The test sources now use
fpcunit.cd dunit fpc -Mdelphiunicode -dUNICODE -dFPC_UNICODE -Fu../Source -Fi../Source fpcconsole.lpr ./fpcconsole --all --format=plainCompatibility notes
TPSVariantIFChas a new field,ConstParam.ImportDecland the export declaration can hold new values (#2,&). Bytecode compiled by an older version still loads, and such parameters count as by value.Not covered
array of constand open array parameters in the method handler.btProcPtr) as parameters in the method handler.