Skip to content

Fix building on linux (arm) #399

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

Closed
wants to merge 1 commit into from
Closed

Fix building on linux (arm) #399

wants to merge 1 commit into from

Conversation

karwa
Copy link
Contributor

@karwa karwa commented May 31, 2016

Without this, we're unable to build on Debian (armv7) because of a conflicting va_list definition.

The include doesn't seem to be required, and removing needless includes is usually a good idea anyway.

See: https://bugs.swift.org/browse/SR-1412

@hpux735
Copy link
Contributor

hpux735 commented May 31, 2016

Thanks for working on this, @karwa. It's weird that this appeared. I'm curious what caused it to happen.

@phausler
Copy link
Contributor

I don't think we can merge this change as is; the include is needed by Foundation and other projects that include that on Darwin. It would be better that if this is somehow a failure on linux to include this header that perhaps we gate that include somehow? That way the change is actually mergeable into the Darwin builds of Foundation/CoreFoundation.

Fixes building on linux (arm)
@karwa
Copy link
Contributor Author

karwa commented May 31, 2016

@phausler Actually, turns out we only need to remove it from the SwiftRuntime/CoreFoundation.h umbrella header. Basically - we shouldn't export stdio from CoreFoundation swift module. For some reason when it's in the module it causes conflicts between clang builtin headers and system headers.

Is that better?

@gribozavr
Copy link
Contributor

gribozavr commented May 31, 2016

because of a conflicting va_list definition

What is defining the second va_list? The only header that can define va_list is stdarg.h that is shipped with the compiler. Different compilers, and different architectures, can define va_list differently depending on the ABI. Trying to match that definition by providing a second definition else is asking for trouble.

@karwa
Copy link
Contributor Author

karwa commented May 31, 2016

@gribozavr It's in the bug report. stdarg.h has a comment about some kind of Ubuntu 'hack', and I've been finding occurrences of what looks like the same problem going back to 2012/13.

This isn't really a fix, more of a workaround.

/home/ryan/Source/build/Ninja-ReleaseAssert/swift-linux-armv7/lib/swift/clang/include/stdarg.h:30:27: note: candidate found by name lookup is 'va_list'
typedef __builtin_va_list va_list;
                          ^
/usr/include/stdio.h:79:20: note: candidate found by name lookup is 'va_list'
typedef _G_va_list va_list;

@parkera
Copy link
Contributor

parkera commented Jun 19, 2016

Hm, I'm still not sure about this one.

@rfdickerson
Copy link

Yeah- I can confirm the duplicate definition of va_args is causing Foundation and libDispatch to fail when building on ARM (like Ubuntu Mate for Raspberry Pi). Commenting out stdio.h fixes it. As an alternative, adding the following to /usr/lib/swift/clang/include/stdarg.h seems to fix it also:

#ifndef _VA_LIST
#include <_G_config.h>  //Adding this line 
typedef __builtin_va_list va_list;
#define _VA_LIST
#endif

@hpux735
Copy link
Contributor

hpux735 commented Aug 19, 2016

I think I have some more context to add to this.

<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "dispatch.h"
         ^
/mnt/build/swift-sources/swift-corelibs-libdispatch/dispatch/dispatch.h:68:10: note: in file included from /mnt/build/swift-sources/swift-corelibs-libdispatch/dispatch/dispatch.h:68:
#include <dispatch/object.h>
         ^
/mnt/build/swift-sources/swift-corelibs-libdispatch/dispatch/object.h:554:64: error: reference to 'va_list' is ambiguous
dispatch_debugv(dispatch_object_t object, const char *message, va_list ap);
                                                               ^
/mnt/build/swift-sources/build/Ninja-ReleaseAssert/swift-linux-armv7/lib/swift/clang/include/stdarg.h:30:27: note: candidate found by name lookup is 'va_list'
typedef __builtin_va_list va_list;
                          ^
/usr/include/stdio.h:79:20: note: candidate found by name lookup is 'va_list'
typedef _G_va_list va_list;
                   ^
/mnt/build/swift-sources/swift-corelibs-libdispatch/src/swift/Block.swift:13:8: error: could not build Objective-C module 'CDispatch'
import CDispatch
       ^

Is the complete text of the same error in libdispatch (see swiftlang/swift-corelibs-libdispatch#155 ). If you look at the system /usr/include/stdio.h it defines va_list, but it makes a feeble attempt to make sure it's only defined if using GNU C:

#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# ifdef __GNUC__
#  ifndef _VA_LIST_DEFINED
typedef _G_va_list va_list;
#   define _VA_LIST_DEFINED
#  endif
# else
#  include <stdarg.h>
# endif
#endif

Before #include <stdio.h> I tried #undef __GNUC__ but it didn't work for some reason. I'm a little surprised it's being redefined in such a way.

@parkera
Copy link
Contributor

parkera commented Oct 6, 2016

This has been superseded by #603.

@parkera parkera closed this Oct 6, 2016
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Oct 11, 2023
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.

7 participants