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

[SR-2239] CVaListPointer does not gets converted to va_list on aarch64 #44846

Open
gonzalolarralde opened this issue Aug 1, 2016 · 8 comments
Open

Comments

@gonzalolarralde
Copy link
Contributor

@gonzalolarralde gonzalolarralde commented Aug 1, 2016

Previous ID SR-2239
Radar None
Original Reporter @gonzalolarralde
Type Bug
Environment

OS: Ubuntu 16.04 xenial
Kernel: 3.10.65-7-pine64-longsleep #28 SMP PREEMPT Sat Apr 23 20:13:25 CEST 2016 aarch64 aarch64 aarch64 GNU/Linux
CPU: Cortex A53 / ARMv8-A (active state AArch64) @ 1.2Ghz x 4 cores
Board: Pine64

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, ClangImporter, Linux, aarch64
Assignee @compnerd
Priority Medium

md5: 9e146d43940f2f8d25705b8c9685e5fc

is duplicated by:

  • SR-5925 non-Darwin aarch64 fails to map va_list to CVaListPointer

Issue Description:

I'm getting an error when trying to compile corelibs-foundation in arm. When the compile process is done with CoreFoundation and gets to the Swift wrappers, it's failing trying to compile NSString.init(format: String: arguments: CVaListPointer) and sibling methods.

cannot convert value of type 'CVaListPointer' to expected argument type 'va_list' (aka '__va_list')

SR-1412 reported problems when trying to resolve the correct va_list in arm. Based on the error message we're getting, and what was the issue at that time, my theory is swift project is resolving va_list and __va_list in a different way as corelibs-foundation does for arm's toolchain. Then the mapped types defined here are failing to work:

// stdarg.h types.
// FIXME: why does this not catch va_list on x86_64?
MAP_STDLIB_TYPE("va_list", VaList, 0, "CVaListPointer", false, DoNothing)
MAP_STDLIB_TYPE("__gnuc_va_list", VaList, 0, "CVaListPointer", false, DoNothing)
MAP_STDLIB_TYPE("__va_list", VaList, 0, "CVaListPointer", false, DoNothing)

// stdarg.h types.
// FIXME: why does this not catch va_list on x86_64?
MAP_STDLIB_TYPE("va_list", VaList, 0, "CVaListPointer", false, DoNothing)
MAP_STDLIB_TYPE("__gnuc_va_list", VaList, 0, "CVaListPointer", false, DoNothing)
MAP_STDLIB_TYPE("__va_list", VaList, 0, "CVaListPointer", false, DoNothing)

Again, is just a theory, I couldn't prove it yet.

Complete compilation call as executed by the build script with the following parameters:

utils/build-script -R --libdispatch 1 --xctest 1 --foundation 1

ubuntu@localhost:~/swift-source/swift-corelibs-foundation$ /home/ubuntu/swift-source/build/Ninja-ReleaseAssert/swift-linux-aarch64/bin/swift -frontend -c Foundation/NSObject.swift Foundation/NSAffineTransform.swift Foundation/NSArray.swift Foundation/NSAttributedString.swift Foundation/NSBundle.swift Foundation/NSByteCountFormatter.swift Foundation/NSCache.swift Foundation/NSCalendar.swift Foundation/NSCFArray.swift Foundation/NSCFDictionary.swift Foundation/NSCFSet.swift Foundation/NSCFString.swift Foundation/NSCharacterSet.swift Foundation/NSCFCharacterSet.swift Foundation/NSCoder.swift Foundation/NSComparisonPredicate.swift Foundation/NSCompoundPredicate.swift Foundation/NSConcreteValue.swift Foundation/NSData.swift Foundation/NSDate.swift Foundation/NSDateComponentsFormatter.swift Foundation/NSDateFormatter.swift Foundation/NSDateIntervalFormatter.swift Foundation/NSDecimal.swift Foundation/NSDecimalNumber.swift Foundation/NSDictionary.swift Foundation/NSEnergyFormatter.swift Foundation/NSEnumerator.swift Foundation/NSError.swift Foundation/NSExpression.swift Foundation/NSFileHandle.swift Foundation/NSFileManager.swift Foundation/NSFormatter.swift Foundation/NSGeometry.swift Foundation/NSHost.swift Foundation/NSHTTPCookie.swift Foundation/NSHTTPCookieStorage.swift Foundation/NSIndexPath.swift Foundation/NSIndexSet.swift Foundation/NSJSONSerialization.swift Foundation/NSKeyedCoderOldStyleArray.swift Foundation/NSKeyedArchiver.swift Foundation/NSKeyedUnarchiver.swift Foundation/NSLengthFormatter.swift Foundation/NSLocale.swift Foundation/NSLock.swift Foundation/NSLog.swift Foundation/NSMassFormatter.swift Foundation/NSNotification.swift Foundation/NSNotificationQueue.swift Foundation/NSNull.swift Foundation/NSNumber.swift Foundation/NSNumberFormatter.swift Foundation/NSObjCRuntime.swift Foundation/NSOperation.swift Foundation/NSOrderedSet.swift Foundation/NSPathUtilities.swift Foundation/NSPersonNameComponents.swift Foundation/NSPersonNameComponentsFormatter.swift Foundation/NSPort.swift Foundation/NSPortMessage.swift Foundation/NSPredicate.swift Foundation/NSProcessInfo.swift Foundation/NSProgress.swift Foundation/NSPropertyList.swift Foundation/NSRange.swift Foundation/NSRegularExpression.swift Foundation/NSRunLoop.swift Foundation/NSScanner.swift Foundation/NSSet.swift Foundation/NSSortDescriptor.swift Foundation/NSSpecialValue.swift Foundation/NSStream.swift -primary-file Foundation/NSString.swift Foundation/String.swift Foundation/NSSwiftRuntime.swift Foundation/NSTask.swift Foundation/NSTextCheckingResult.swift Foundation/NSThread.swift Foundation/NSTimer.swift Foundation/NSTimeZone.swift Foundation/NSURL.swift Foundation/NSURLAuthenticationChallenge.swift Foundation/NSURLCache.swift Foundation/NSURLCredential.swift Foundation/NSURLCredentialStorage.swift Foundation/NSURLError.swift Foundation/NSURLProtectionSpace.swift Foundation/NSURLProtocol.swift Foundation/NSURLRequest.swift Foundation/NSURLResponse.swift Foundation/NSURLSession.swift Foundation/NSUserDefaults.swift Foundation/NSUUID.swift Foundation/NSValue.swift Foundation/NSXMLDocument.swift Foundation/NSXMLDTD.swift Foundation/NSXMLDTDNode.swift Foundation/NSXMLElement.swift Foundation/NSXMLNode.swift Foundation/NSXMLNodeOptions.swift Foundation/NSXMLParser.swift Foundation/FoundationErrors.swift Foundation/URL.swift Foundation/Boxing.swift Foundation/ReferenceConvertible.swift Foundation/Date.swift Foundation/Data.swift Foundation/CharacterSet.swift Foundation/URLRequest.swift Foundation/PersonNameComponents.swift Foundation/Notification.swift Foundation/URLComponents.swift Foundation/DateComponents.swift Foundation/DateInterval.swift Foundation/IndexPath.swift Foundation/IndexSet.swift Foundation/NSStringEncodings.swift Foundation/ExtraStringAPIs.swift Foundation/Measurement.swift Foundation/NSMeasurement.swift Foundation/NSMeasurementFormatter.swift Foundation/Unit.swift -I/home/ubuntu/swift-source/build/Ninja-ReleaseAssert/swift-linux-aarch64/lib/swift/linux -Xcc -fblocks -resource-dir /home/ubuntu/swift-source/build/Ninja-ReleaseAssert/swift-linux-aarch64/lib/swift -target aarch64-unknown-linux   -Ibootstrap/common/usr/include -Ibootstrap/common/usr/local/include   -Ibootstrap/aarch64-linux-gnu/usr/include -Ibootstrap/aarch64-linux-gnu/usr/local/include -O  -I../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation -I../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/usr//lib/swift -I../build/Ninja-ReleaseAssert/foundation-linux-aarch64 -I../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/usr/lib/swift -I/usr/include/libxml2 -I/home/ubuntu/swift-source/build/Ninja-ReleaseAssert/xctest-linux-aarch64 -L/home/ubuntu/swift-source/build/Ninja-ReleaseAssert/xctest-linux-aarch64 -I/usr/include/libxml2 -DDEPLOYMENT_ENABLE_LIBDISPATCH -I/home/ubuntu/swift-source/swift-corelibs-libdispatch -I/home/ubuntu/swift-source/build/Ninja-ReleaseAssert/libdispatch-linux-aarch64/src/swift -Xcc -fblocks -module-name Foundation -module-link-name Foundation -o ../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/Foundation/NSString.swift.o -emit-module-path ../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/Foundation/NSString.swift.o.~partial.swiftmodule -emit-module-doc-path ../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/Foundation/NSString.swift.o.~partial.swiftdoc -emit-dependencies-path ../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/Foundation/NSString.swift.o.d -emit-reference-dependencies-path ../build/Ninja-ReleaseAssert/foundation-linux-aarch64/Foundation/Foundation/NSString.swift.o.swiftdeps -module-cache-path ../build/Ninja-ReleaseAssert/foundation-linux-aarch64
Foundation/NSString.swift:1198:106: error: cannot convert value of type 'CVaListPointer' to expected argument type 'va_list' (aka '__va_list')
        let str = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, nil, format._cfObject, argList)!
                                                                                                         ^~~~~~~
Foundation/NSString.swift:1206:148: error: cannot convert value of type 'CVaListPointer' to expected argument type 'va_list' (aka '__va_list')
                str = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, unsafeBitCast(loc, to: CFDictionary.self), format._cfObject, argList)
                                                                                                                                                   ^~~~~~~
Foundation/NSString.swift:1211:106: error: cannot convert value of type 'CVaListPointer' to expected argument type 'va_list' (aka '__va_list')
            str = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, nil, format._cfObject, argList)
                                                                                                         ^~~~~~~
Foundation/NSString.swift:1218:100: error: cannot convert value of type 'CVaListPointer' to expected argument type 'va_list' (aka '__va_list')
            CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, nil, format._cfObject, vaPtr)
                                                                                                   ^~~~~
@gonzalolarralde
Copy link
Contributor Author

@gonzalolarralde gonzalolarralde commented Aug 1, 2016

I think it worths to be said that the exact same codebase checked out at the same time in a x86_64 linux 16.04 emulator worked fine. This seems to be an arm only issue.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Sep 14, 2016

Comment by Neon (JIRA)

I just learned that arm aarch64 != apple arm64.

The arm aarch64 ABI defines __va_list as:

struct __va_list
   {
     void *__stack;
     void *__gr_top;
     void *__vr_top;
     int   __gr_offs;
     int   __vr_offs;
   };

but for apple arm64 it is char*.

Is it possible that swift is only working with apple arm64 but clang has arm aarch64 implemented?

@modocache
Copy link
Mannequin

@modocache modocache mannequin commented Jan 1, 2017

Is this issue related to https://bugs.swift.org/browse/SR-3429 ?

@compnerd
Copy link
Collaborator

@compnerd compnerd commented Oct 22, 2017

@modocache, unlikely that they are related. This would need to work before that can even occur as this issue prevents the definition of `CVaListPointer` entirely.

@compnerd
Copy link
Collaborator

@compnerd compnerd commented Oct 26, 2017

Partial WIP patch at apple/swift#12623. The ClangImporter still needs adjustment and _VaListBuilder needs to be completed.

@compnerd
Copy link
Collaborator

@compnerd compnerd commented Nov 2, 2017

The only bit that remains is fixing the _VaListBuilder which seems to not be getting interpreted properly.

@futurejones
Copy link
Contributor

@futurejones futurejones commented Jun 21, 2018

We now have a fix for this issue.

apple/swift#15174

This fix has been tested on a variety of arm64/aarch64 devices, from small SBC's like the RaspberryPi and Rock64, to high end Cavium ThunderX servers.

We need this issue resolved urgently as it is blocking successful builds on the new AArch64 CI - https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Jun 27, 2018

Comment by Ed Vielmetti (JIRA)

@compnerd please take a look? We have a new CI system ready to go, blocked at the moment on this bug.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants