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

powerpc64: improve extern struct ABI #44066

Merged
merged 4 commits into from
Sep 2, 2017

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Aug 23, 2017

These fixes all have to do with the 64-bit PowerPC ELF ABI for big-endian
targets. The ELF v2 ABI for powerpc64le already worked well.

  • Return after marking return aggregates indirect. Fixes ICE: assertion failed in ppc64 make_indirect #42757.
  • Pass one-member float aggregates as direct argument values.
  • Aggregate arguments less than 64-bit must be written in the least-
    significant bits of the parameter space.
  • Larger aggregates are instead padded at the tail.
    (i.e. filling MSBs, padding the remaining LSBs.)

New tests were also added for the single-float aggregate, and a 3-byte
aggregate to check that it's filled into LSBs. Overall, at least these
formerly-failing tests now pass on powerpc64:

  • run-make/extern-fn-struct-passing-abi
  • run-make/extern-fn-with-packed-struct
  • run-pass/extern-pass-TwoU16s.rs
  • run-pass/extern-pass-TwoU8s.rs
  • run-pass/struct-return.rs

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

@bors: r+

Nice fixes!

@bors
Copy link
Contributor

bors commented Aug 24, 2017

📌 Commit fdd889d has been approved by alexcrichton

@alexcrichton alexcrichton added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 24, 2017
@bors
Copy link
Contributor

bors commented Aug 26, 2017

⌛ Testing commit fdd889d with merge d289ee4...

bors added a commit that referenced this pull request Aug 26, 2017
powerpc64: improve extern struct ABI

These fixes all have to do with the 64-bit PowerPC ELF ABI for big-endian
targets.  The ELF v2 ABI for powerpc64le already worked well.

- Return after marking return aggregates indirect. Fixes #42757.
- Pass one-member float aggregates as direct argument values.
- Aggregate arguments less than 64-bit must be written in the least-
  significant bits of the parameter space.
- Larger aggregates are instead padded at the tail.
  (i.e. filling MSBs, padding the remaining LSBs.)

New tests were also added for the single-float aggregate, and a 3-byte
aggregate to check that it's filled into LSBs.  Overall, at least these
formerly-failing tests now pass on powerpc64:

- run-make/extern-fn-struct-passing-abi
- run-make/extern-fn-with-packed-struct
- run-pass/extern-pass-TwoU16s.rs
- run-pass/extern-pass-TwoU8s.rs
- run-pass/struct-return.rs
@alexcrichton
Copy link
Member

@bors: r-

Apparently this found an existing bug :(

[01:08:25] ---- [run-make] run-make\extern-fn-struct-passing-abi stdout ----
[01:08:25] 	
[01:08:25] error: make failed
[01:08:25] status: exit code: 2
[01:08:25] command: "make"
[01:08:25] stdout:
[01:08:25] ------------------------------------------
[01:08:25] gcc.exe -ffunction-sections -fdata-sections -m64 -c -o /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu/libtest.o test.c
[01:08:25] ar crus /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu/test.lib /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu/libtest.o
[01:08:25] PATH="/c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu:C:\projects\rust\build\x86_64-pc-windows-gnu\stage2\bin:/c/projects/rust/build/x86_64-pc-windows-gnu/stage0-tools/x86_64-pc-windows-gnu/release/deps:/c/projects/rust/build/x86_64-pc-windows-gnu/stage0-sysroot/lib/rustlib/x86_64-pc-windows-gnu/lib:/c/Program Files (x86)/Inno Setup 5:/c/Python27:/c/projects/rust/mingw64/bin:/usr/bin:/c/Perl/site/bin:/c/Perl/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/7-Zip:/c/Program Files/Microsoft/Web Platform Installer:/c/Tools/GitVersion:/c/Tools/PsTools:/c/Program Files/Git LFS:/c/Program Files (x86)/Subversion/bin:/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio:/c/Tools/WebDriver:/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.4:/c/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI/wbin:/c/Ruby193/bin:/c/Tools/NUnit/bin:/c/Tools/xUnit:/c/Tools/MSpec:/c/Tools/Coverity/bin:/c/Program Files (x86)/CMake/bin:/c/go/bin:/c/Program Files/Java/jdk1.8.0/bin:/c/Python27:/c/Program Files/nodejs:/c/Program Files (x86)/iojs:/c/Program Files/iojs:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/MSBuild/14.0/Bin:/c/Tools/NuGet:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Apache/Maven/bin:/c/Python27/Scripts:/c/Tools/NUnit3:/c/Program Files/Mercurial:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files/erl8.3/bin:/c/Tools/curl/bin:/c/Program Files/Amazon/AWSCLI:/c/Program Files/Git/cmd:/c/Program Files/Git/usr/bin:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/Extensions/Microsoft/SQLDB/DAC/140:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Yarn/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files (x86)/nodejs:/c/Users/appveyor/AppData/Local/Yarn/bin:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/AppVeyor/BuildAgent:/c/projects/rust:/c/projects/rust/handle" 'C:\projects\rust\build\x86_64-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu -L /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu  test.rs
[01:08:25] PATH="/c/projects/rust/build/x86_64-pc-windows-gnu/stage0-tools/x86_64-pc-windows-gnu/release/deps:/c/projects/rust/build/x86_64-pc-windows-gnu/stage0-sysroot/lib/rustlib/x86_64-pc-windows-gnu/lib:/c/Program Files (x86)/Inno Setup 5:/c/Python27:/c/projects/rust/mingw64/bin:/usr/bin:/c/Perl/site/bin:/c/Perl/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/7-Zip:/c/Program Files/Microsoft/Web Platform Installer:/c/Tools/GitVersion:/c/Tools/PsTools:/c/Program Files/Git LFS:/c/Program Files (x86)/Subversion/bin:/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio:/c/Tools/WebDriver:/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.4:/c/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI/wbin:/c/Ruby193/bin:/c/Tools/NUnit/bin:/c/Tools/xUnit:/c/Tools/MSpec:/c/Tools/Coverity/bin:/c/Program Files (x86)/CMake/bin:/c/go/bin:/c/Program Files/Java/jdk1.8.0/bin:/c/Python27:/c/Program Files/nodejs:/c/Program Files (x86)/iojs:/c/Program Files/iojs:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/MSBuild/14.0/Bin:/c/Tools/NuGet:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Apache/Maven/bin:/c/Python27/Scripts:/c/Tools/NUnit3:/c/Program Files/Mercurial:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files/erl8.3/bin:/c/Tools/curl/bin:/c/Program Files/Amazon/AWSCLI:/c/Program Files/Git/cmd:/c/Program Files/Git/usr/bin:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/Extensions/Microsoft/SQLDB/DAC/140:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Yarn/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files (x86)/nodejs:/c/Users/appveyor/AppData/Local/Yarn/bin:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/AppVeyor/BuildAgent:/c/projects/rust:/c/projects/rust/handle:C:\projects\rust\build\x86_64-pc-windows-gnu\stage2\lib\rustlib\x86_64-pc-windows-gnu\lib" /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu/test || exit 1
[01:08:25] rm /c/projects/rust/build/x86_64-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu/libtest.o
[01:08:25] 
[01:08:25] ------------------------------------------
[01:08:25] stderr:
[01:08:25] ------------------------------------------
[01:08:25] 
[01:08:25] This application has requested the Runtime to terminate it in an unusual way.
[01:08:25] Please contact the application's support team for more information.
[01:08:25] Assertion failed!
[01:08:25] 
[01:08:25] Program: C:\projects\rust\build\x86_64-pc-windows-gnu\test\run-make\extern-fn-struct-passing-abi.stage2-x86_64-pc-windows-gnu\test.exe
[01:08:25] File: test.c, Line 310
[01:08:25] 
[01:08:25] Expression: f1.x == 7.
[01:08:25] make: *** [Makefile:5: all] Error 1
[01:08:25] 
[01:08:25] ------------------------------------------
[01:08:25] 
[01:08:25] thread '[run-make] run-make\extern-fn-struct-passing-abi' panicked at 'explicit panic', src\tools\compiletest\src\runtest.rs:2435:8
[01:08:25] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:08:25] 
[01:08:25] 
[01:08:25] failures:
[01:08:25]     [run-make] run-make\extern-fn-struct-passing-abi
[01:08:25] 
[01:08:25] test result: FAILED. 158 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:08:25] 
[01:08:25] thread 'main' panicked at 'Some tests failed', src\tools\compiletest\src\main.rs:322:21
[01:08:25] 

@alexcrichton
Copy link
Member

@bors: retry

@carols10cents
Copy link
Member

@bors: retry

I've seen a lot of PRs that look like they're still running in github but travis has finished? Like a webhook request to github hasn't happened or something.

@arielb1 arielb1 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 29, 2017
@arielb1
Copy link
Contributor

arielb1 commented Aug 29, 2017

@bors r-

See appveyor failure

@cuviper
Copy link
Member Author

cuviper commented Aug 29, 2017

For struct FloatOne { double x; }, it appears that MSVC passes the parameter in RCX and returns in RAX, but mingw-gcc passes the parameter and return value both in XMM0. Mingw-clang does the same as MSVC, so I think this is a GCC bug.

I'll go file that in GCC bugzilla, but what do you suggest we do here in the meantime?

@cuviper
Copy link
Member Author

cuviper commented Aug 29, 2017

@alexcrichton
Copy link
Member

what do you suggest we do here in the meantime?

Perhaps just ignore the test on MinGW?

@cuviper
Copy link
Member Author

cuviper commented Aug 29, 2017

OK, I disabled float_one just for win64-gnu -- let's hope the rest are OK.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 29, 2017

📌 Commit dd8f4eb has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 30, 2017

⌛ Testing commit dd8f4ebf5a784e82da96e49cb08e7de573902618 with merge e933fcfd9b05d0d5372911e68cee3551b6d21721...

@bors
Copy link
Contributor

bors commented Aug 30, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member

Looks like another likely preexising bug?

[01:30:07] ---- [run-make] run-make\extern-fn-struct-passing-abi stdout ----
[01:30:07] 	
[01:30:07] error: make failed
[01:30:07] status: exit code: 2
[01:30:07] command: "make"
[01:30:07] stdout:
[01:30:07] ------------------------------------------
[01:30:07] gcc.exe -ffunction-sections -fdata-sections -m32 -fno-omit-frame-pointer -c -o /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu/libtest.o test.c
[01:30:07] ar crus /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu/test.lib /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu/libtest.o
[01:30:07] PATH="/c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu:C:\projects\rust\build\i686-pc-windows-gnu\stage2\bin:/c/projects/rust/build/i686-pc-windows-gnu/stage0-tools/i686-pc-windows-gnu/release/deps:/c/projects/rust/build/i686-pc-windows-gnu/stage0-sysroot/lib/rustlib/i686-pc-windows-gnu/lib:/c/Program Files (x86)/Inno Setup 5:/c/Python27:/c/projects/rust/mingw32/bin:/usr/bin:/c/Perl/site/bin:/c/Perl/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/7-Zip:/c/Program Files/Microsoft/Web Platform Installer:/c/Tools/GitVersion:/c/Tools/PsTools:/c/Program Files/Git LFS:/c/Program Files (x86)/Subversion/bin:/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio:/c/Tools/WebDriver:/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.4:/c/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI/wbin:/c/Ruby193/bin:/c/Tools/NUnit/bin:/c/Tools/xUnit:/c/Tools/MSpec:/c/Tools/Coverity/bin:/c/Program Files (x86)/CMake/bin:/c/go/bin:/c/Program Files/Java/jdk1.8.0/bin:/c/Python27:/c/Program Files/nodejs:/c/Program Files (x86)/iojs:/c/Program Files/iojs:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/MSBuild/14.0/Bin:/c/Tools/NuGet:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Apache/Maven/bin:/c/Python27/Scripts:/c/Tools/NUnit3:/c/Program Files/Mercurial:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files/erl8.3/bin:/c/Tools/curl/bin:/c/Program Files/Amazon/AWSCLI:/c/Program Files/Git/cmd:/c/Program Files/Git/usr/bin:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/Extensions/Microsoft/SQLDB/DAC/140:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Yarn/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files (x86)/nodejs:/c/Users/appveyor/AppData/Local/Yarn/bin:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/AppVeyor/BuildAgent:/c/projects/rust:/c/projects/rust/handle" 'C:\projects\rust\build\i686-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu -L /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu  test.rs
[01:30:07] PATH="/c/projects/rust/build/i686-pc-windows-gnu/stage0-tools/i686-pc-windows-gnu/release/deps:/c/projects/rust/build/i686-pc-windows-gnu/stage0-sysroot/lib/rustlib/i686-pc-windows-gnu/lib:/c/Program Files (x86)/Inno Setup 5:/c/Python27:/c/projects/rust/mingw32/bin:/usr/bin:/c/Perl/site/bin:/c/Perl/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/7-Zip:/c/Program Files/Microsoft/Web Platform Installer:/c/Tools/GitVersion:/c/Tools/PsTools:/c/Program Files/Git LFS:/c/Program Files (x86)/Subversion/bin:/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio:/c/Tools/WebDriver:/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.4:/c/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI/wbin:/c/Ruby193/bin:/c/Tools/NUnit/bin:/c/Tools/xUnit:/c/Tools/MSpec:/c/Tools/Coverity/bin:/c/Program Files (x86)/CMake/bin:/c/go/bin:/c/Program Files/Java/jdk1.8.0/bin:/c/Python27:/c/Program Files/nodejs:/c/Program Files (x86)/iojs:/c/Program Files/iojs:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/MSBuild/14.0/Bin:/c/Tools/NuGet:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/c/Program Files/Microsoft DNX/Dnvm:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Apache/Maven/bin:/c/Python27/Scripts:/c/Tools/NUnit3:/c/Program Files/Mercurial:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files/erl8.3/bin:/c/Tools/curl/bin:/c/Program Files/Amazon/AWSCLI:/c/Program Files/Git/cmd:/c/Program Files/Git/usr/bin:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/Extensions/Microsoft/SQLDB/DAC/140:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Yarn/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files (x86)/nodejs:/c/Users/appveyor/AppData/Local/Yarn/bin:/c/Users/appveyor/AppData/Roaming/npm:/c/Program Files/AppVeyor/BuildAgent:/c/projects/rust:/c/projects/rust/handle:C:\projects\rust\build\i686-pc-windows-gnu\stage2\lib\rustlib\i686-pc-windows-gnu\lib" /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu/test || exit 1
[01:30:07] rm /c/projects/rust/build/i686-pc-windows-gnu/test/run-make/extern-fn-struct-passing-abi.stage2-i686-pc-windows-gnu/libtest.o
[01:30:07] 
[01:30:07] ------------------------------------------
[01:30:07] stderr:
[01:30:07] ------------------------------------------
[01:30:07] thread 'main' panicked at 'assertion failed: `(left == right)`
[01:30:07]   left: `FloatOne { x: 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006946625899997187 }`,
[01:30:07]  right: `FloatOne { x: 7 }`', test.rs:141:8
[01:30:07] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:30:07] make: *** [Makefile:5: all] Error 1
[01:30:07] 
[01:30:07] ------------------------------------------
[01:30:07] 
[01:30:07] thread '[run-make] run-make\extern-fn-struct-passing-abi' panicked at 'explicit panic', src\tools\compiletest\src\runtest.rs:2435:8
[01:30:07] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:30:07] 
[01:30:07] 
[01:30:07] failures:
[01:30:07]     [run-make] run-make\extern-fn-struct-passing-abi
[01:30:07] 
[01:30:07] test result: FAILED. 158 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

@cuviper
Copy link
Member Author

cuviper commented Aug 30, 2017

For i686, cl returns FloatOne in EDX:EAX, but gcc and clang use ST0 like you would for bare floats. Rust is trying to read the return values from EDX:EAX like cl produces.

Unlike the Win64 case, it's not as clear to me if this is a true ABI problem or if it's just a difference in cdecl between msvc and gnu flavors. I guess I can file a GCC bug and see what they say, and mask the test for all windows-gnu in the meantime.

@alexcrichton
Copy link
Member

Nice investigation! I"m totally ok w/ just ignoring the test for now and waiting to see what upstream says

@cuviper
Copy link
Member Author

cuviper commented Aug 30, 2017

OK, I filed gcc 82041 and further masked the test.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 30, 2017

📌 Commit ff9b6f7 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 31, 2017

⌛ Testing commit ff9b6f7a73a0e9c786b30959c92735db344efbd1 with merge dddd749ea0fe9df7076b8091cfca3fa676199535...

@bors
Copy link
Contributor

bors commented Aug 31, 2017

💔 Test failed - status-travis

@kennytm
Copy link
Member

kennytm commented Aug 31, 2017

check i686-apple-darwin failed, still the extern-fn-struct-passing-abi test, legit.

[01:51:45] failures:
[01:51:45] 
[01:51:45] ---- [run-make] run-make/extern-fn-struct-passing-abi stdout ----
[01:51:45] 	
[01:51:45] error: make failed
[01:51:45] status: exit code: 2
[01:51:45] command: "make"
[01:51:45] stdout:
[01:51:45] ------------------------------------------
[01:51:45] cc -ffunction-sections -fdata-sections -fPIC -m32 -stdlib=libc++ -c -o /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin/libtest.o test.c
[01:51:45] ar crus /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin/libtest.a /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin/libtest.o
[01:51:45] DYLD_LIBRARY_PATH="/Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin:/Users/travis/build/rust-lang/rust/build/i686-apple-darwin/stage2/lib:" '/Users/travis/build/rust-lang/rust/build/i686-apple-darwin/stage2/bin/rustc' --out-dir /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin -L /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin  test.rs
[01:51:45] DYLD_LIBRARY_PATH="/Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin:/Users/travis/build/rust-lang/rust/build/i686-apple-darwin/stage2/lib/rustlib/i686-apple-darwin/lib:" /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin/test || exit 1
[01:51:45] rm /Users/travis/build/rust-lang/rust/build/i686-apple-darwin/test/run-make/extern-fn-struct-passing-abi.stage2-i686-apple-darwin/libtest.o
[01:51:45] 
[01:51:45] ------------------------------------------
[01:51:45] stderr:
[01:51:45] ------------------------------------------
[01:51:45] thread 'main' panicked at 'assertion failed: `(left == right)`
[01:51:45]   left: `FloatOne { x: -1.673584938129909 }`,
[01:51:45]  right: `FloatOne { x: 7 }`', test.rs:142:8
[01:51:45] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:51:45] make[1]: *** [all] Error 1
[01:51:45] 
[01:51:45] ------------------------------------------
[01:51:45] 
[01:51:45] thread '[run-make] run-make/extern-fn-struct-passing-abi' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2435:8
[01:51:45] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:51:45] 
[01:51:45] 
[01:51:45] failures:
[01:51:45]     [run-make] run-make/extern-fn-struct-passing-abi
[01:51:45] 
[01:51:45] test result: �[31mFAILED�(B�[m. 158 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

@cuviper
Copy link
Member Author

cuviper commented Sep 1, 2017

I don't have macOS to test on, but using clang --target=i686-apple-darwin it looks like the FloatOne return value will be in ST0, whereas rustc is trying to read it from EDX:EAX. Basically the same situation as i686-pc-windows-gnu, although clang is probably the authority in this case. (assuming my Fedora's clang does indeed use the same ABI as AppleClang.)

@alexcrichton
Copy link
Member

@cuviper if it helps on a Mac I've got when I compile this code I get this 32-bit assembly and this 64-bit assembly

@cuviper
Copy link
Member Author

cuviper commented Sep 1, 2017

Thanks! Your 64-bit asm is passing and returning in XMM0, which must be fine since the test did pass on x86_64-apple-darwin (before the job was canceled). Your 32-bit asm returns the value in ST0 like I saw too, with the flds load before returning.

These fixes all have to do with the 64-bit PowerPC ELF ABI for big-endian
targets.  The ELF v2 ABI for powerpc64le already worked well.

- Return after marking return aggregates indirect. Fixes rust-lang#42757.
- Pass one-member float aggregates as direct argument values.
- Aggregate arguments less than 64-bit must be written in the least-
  significant bits of the parameter space.
- Larger aggregates are instead padded at the tail.
  (i.e. filling MSBs, padding the remaining LSBs.)

New tests were also added for the single-float aggregate, and a 3-byte
aggregate to check that it's filled into LSBs.  Overall, at least these
formerly-failing tests now pass on powerpc64:

- run-make/extern-fn-struct-passing-abi
- run-make/extern-fn-with-packed-struct
- run-pass/extern-pass-TwoU16s.rs
- run-pass/extern-pass-TwoU8s.rs
- run-pass/struct-return.rs
Following Clang's lead, and anecdotal evidence from the `float_one` part
of `run-make/extern-fn-struct-passing-abi`, use a floating point
register to return single-float aggregates, except on MSVC targets.
@cuviper
Copy link
Member Author

cuviper commented Sep 2, 2017

OK, I think that will fix i686. Following Clang's lead, I have FloatOne returned in ST0 instead of EDX:EAX everywhere except MSVC. This even lets i686-pc-windows-gnu pass, but I'll leave that masked until the gcc bug confirms whether that ABI is intended.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 2, 2017

📌 Commit 40b1473 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Sep 2, 2017

⌛ Testing commit 40b1473 with merge 744dd6c...

bors added a commit that referenced this pull request Sep 2, 2017
powerpc64: improve extern struct ABI

These fixes all have to do with the 64-bit PowerPC ELF ABI for big-endian
targets.  The ELF v2 ABI for powerpc64le already worked well.

- Return after marking return aggregates indirect. Fixes #42757.
- Pass one-member float aggregates as direct argument values.
- Aggregate arguments less than 64-bit must be written in the least-
  significant bits of the parameter space.
- Larger aggregates are instead padded at the tail.
  (i.e. filling MSBs, padding the remaining LSBs.)

New tests were also added for the single-float aggregate, and a 3-byte
aggregate to check that it's filled into LSBs.  Overall, at least these
formerly-failing tests now pass on powerpc64:

- run-make/extern-fn-struct-passing-abi
- run-make/extern-fn-with-packed-struct
- run-pass/extern-pass-TwoU16s.rs
- run-pass/extern-pass-TwoU8s.rs
- run-pass/struct-return.rs
@bors
Copy link
Contributor

bors commented Sep 2, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 744dd6c to master...

@bors bors merged commit 40b1473 into rust-lang:master Sep 2, 2017
@cuviper cuviper deleted the powerpc64-extern-abi branch September 26, 2017 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: assertion failed in ppc64 make_indirect
7 participants