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

Building on Windows #56

Open
2 tasks done
stevapple opened this issue Aug 8, 2022 · 11 comments
Open
2 tasks done

Building on Windows #56

stevapple opened this issue Aug 8, 2022 · 11 comments
Labels
bug Something isn't working

Comments

@stevapple
Copy link

Swift Atomics doesn't compile on Windows.

Information

  • Package version: main, 1.0.2
  • Platform version: Windows 10 21H1
  • Swift version: compnerd.org Swift version 5.6.2 (swift-5.6.2-RELEASE)

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • I've searched for existing reports of the same issue.

Steps to Reproduce

Clone & checkout the repository on a Windows machine with Swift toolchain installed. Use swift build to compile.

Expected behavior

The package is supposed to compile successfully.

Actual behavior

swift-output.txt

@stevapple stevapple added the bug Something isn't working label Aug 8, 2022
@lorentey
Copy link
Member

lorentey commented Aug 8, 2022

Interesting:

[2/13] Compiling Atomics AtomicOptional.swift
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:96:1: error: use of undeclared identifier 'memory_order_acquire'
SWIFTATOMIC_THREAD_FENCE_FN(acquire)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:93:25: note: expanded from macro 'SWIFTATOMIC_THREAD_FENCE_FN'
    atomic_thread_fence(memory_order_##order);                          \
                        ^
<scratch space>:20:1: note: expanded from here
memory_order_acquire
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:97:1: error: use of undeclared identifier 'memory_order_release'
SWIFTATOMIC_THREAD_FENCE_FN(release)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:93:25: note: expanded from macro 'SWIFTATOMIC_THREAD_FENCE_FN'
    atomic_thread_fence(memory_order_##order);                          \
                        ^
<scratch space>:20:1: note: expanded from here
memory_order_release
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:98:1: error: use of undeclared identifier 'memory_order_acq_rel'
SWIFTATOMIC_THREAD_FENCE_FN(acq_rel)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:93:25: note: expanded from macro 'SWIFTATOMIC_THREAD_FENCE_FN'
    atomic_thread_fence(memory_order_##order);                          \
                        ^
<scratch space>:20:1: note: expanded from here
memory_order_acq_rel
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:99:1: error: use of undeclared identifier 'memory_order_seq_cst'
SWIFTATOMIC_THREAD_FENCE_FN(seq_cst)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:93:25: note: expanded from macro 'SWIFTATOMIC_THREAD_FENCE_FN'
    atomic_thread_fence(memory_order_##order);                          \
                        ^
<scratch space>:20:1: note: expanded from here
memory_order_seq_cst
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:270:1: error: use of undeclared identifier 'memory_order_relaxed'
SWIFTATOMIC_DEFINE_INTEGER_TYPE(SIMPLE, Int, intptr_t, intptr_t)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:260:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_INTEGER_TYPE'
  SWIFTATOMIC_DEFINE_TYPE(variant, swiftType, cType, storageType)      \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:253:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_TYPE'
  SWIFTATOMIC_LOAD_FNS(swiftType, cType, storageType)                  \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:220:3: note: expanded from macro 'SWIFTATOMIC_LOAD_FNS'
  SWIFTATOMIC_LOAD_FN(swiftType, cType, storageType, relaxed)          \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:134:28: note: expanded from macro 'SWIFTATOMIC_LOAD_FN'
                           memory_order_##order));                      \
                           ^
<scratch space>:20:1: note: expanded from here
memory_order_relaxed
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:270:1: error: use of undeclared identifier 'memory_order_acquire'
SWIFTATOMIC_DEFINE_INTEGER_TYPE(SIMPLE, Int, intptr_t, intptr_t)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:260:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_INTEGER_TYPE'
  SWIFTATOMIC_DEFINE_TYPE(variant, swiftType, cType, storageType)      \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:253:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_TYPE'
  SWIFTATOMIC_LOAD_FNS(swiftType, cType, storageType)                  \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:221:3: note: expanded from macro 'SWIFTATOMIC_LOAD_FNS'
  SWIFTATOMIC_LOAD_FN(swiftType, cType, storageType, acquire)          \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:134:28: note: expanded from macro 'SWIFTATOMIC_LOAD_FN'
                           memory_order_##order));                      \
                           ^
<scratch space>:20:1: note: expanded from here
memory_order_acquire
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:270:1: error: use of undeclared identifier 'memory_order_seq_cst'
SWIFTATOMIC_DEFINE_INTEGER_TYPE(SIMPLE, Int, intptr_t, intptr_t)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:260:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_INTEGER_TYPE'
  SWIFTATOMIC_DEFINE_TYPE(variant, swiftType, cType, storageType)      \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:253:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_TYPE'
  SWIFTATOMIC_LOAD_FNS(swiftType, cType, storageType)                  \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:222:3: note: expanded from macro 'SWIFTATOMIC_LOAD_FNS'
  SWIFTATOMIC_LOAD_FN(swiftType, cType, storageType, seq_cst)
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:134:28: note: expanded from macro 'SWIFTATOMIC_LOAD_FN'
                           memory_order_##order));                      \
                           ^
<scratch space>:20:1: note: expanded from here
memory_order_seq_cst
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "_AtomicsShims.h"
         ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:270:1: error: use of undeclared identifier 'memory_order_relaxed'
SWIFTATOMIC_DEFINE_INTEGER_TYPE(SIMPLE, Int, intptr_t, intptr_t)
^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:260:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_INTEGER_TYPE'
  SWIFTATOMIC_DEFINE_TYPE(variant, swiftType, cType, storageType)      \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:254:3: note: expanded from macro 'SWIFTATOMIC_DEFINE_TYPE'
  SWIFTATOMIC_STORE_FNS(swiftType, cType, storageType)                 \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:215:3: note: expanded from macro 'SWIFTATOMIC_STORE_FNS'
  SWIFTATOMIC_STORE_FN(swiftType, cType, storageType, relaxed)         \
  ^
C:\Users\stevapple\workspace\Using\swift-atomics\Sources\_AtomicsShims\include/_AtomicsShims.h:146:27: note: expanded from macro 'SWIFTATOMIC_STORE_FN'
                          memory_order_##order);                        \
                          ^
<scratch space>:20:1: note: expanded from here
memory_order_relaxed
^
(etc)

@lorentey
Copy link
Member

lorentey commented Aug 8, 2022

Presumably enum memory_order is somehow missing from stdatomic.h on this config; we'll need to take a look at the header files that apply here and see where it leads us.

@stevapple
Copy link
Author

stevapple commented Aug 12, 2022

I guess the not-founds are related to swiftc not recognizing Clang’s header include path. This is what I get now:

administrator@iZslngp7ujsw3eZ C:\Users\Administrator\Developer\swift-atomics>swift build -Xswiftc -I -Xswiftc C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\clang\13.0.0\include                                                            
Building for debugging...                                                                 
[1/1] Compiling _AtomicsShims src\_AtomicsShims.c                                         
Assertion failed: Loc.isValid() && "Can't get file characteristic of invalid loc!", file D:\a\1\s\llvm-project\clang\lib\Basic\SourceManager.cpp, line 1473                         
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.                                                                                                                              
Stack dump:                                                                                                                                                     
0.      <eof> parser at end of file                                                                                                                             
 #0 0x00007ff747944345 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x4d14345)                                   
 #1 0x00007fffb557d88d (C:\Windows\System32\ucrtbase.dll+0x6d88d)                                                                                               
 #2 0x00007fffb557e761 (C:\Windows\System32\ucrtbase.dll+0x6e761)                                                                                               
 #3 0x00007fffb55800c1 (C:\Windows\System32\ucrtbase.dll+0x700c1)                                                                                               
 #4 0x00007fffb55803f1 (C:\Windows\System32\ucrtbase.dll+0x703f1)                                                                                               
 #5 0x00007ff7477dcf72 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x4bacf72)                                   
 #6 0x00007ff747784ce8 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x4b54ce8)                                   
 #7 0x00007ff743e37a29 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x1207a29)                                   
 #8 0x00007ff743e52141 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x1222141)                                   
 #9 0x00007ff743e5934f (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x122934f)                                   
#10 0x00007ff74642f776 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x37ff776)                                   
#11 0x00007ff74642377e (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x37f377e)                                   
#12 0x00007ff746420921 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x37f0921)                                   
#13 0x00007ff74644a083 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x381a083)                                   
#14 0x00007ff74616664c (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x353664c)                                   
#15 0x00007ff7462e1ef4 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x36b1ef4)                                   
#16 0x00007ff74614c795 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x351c795)                                   
#17 0x00007ff74614c5a8 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x351c5a8)                                   
#18 0x00007ff746135c2c (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x3505c2c)                                   
#19 0x00007ff746132e3a (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x3502e3a)                                   
#20 0x00007ff747924994 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x4cf4994)                                   
#21 0x00007ff747924b7f (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x4cf4b7f)                                   
#22 0x00007ff74792454f (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe+0x4cf454f)                                   
#23 0x00007fffb553268a (C:\Windows\System32\ucrtbase.dll+0x2268a)                                                                                               
#24 0x00007fffb5d97974 (C:\Windows\System32\KERNEL32.DLL+0x17974)                                                                                               
#25 0x00007fffb8baa2f1 (C:\Windows\SYSTEM32\ntdll.dll+0x5a2f1)

@lorentey Seems a compiler bug now?

@lorentey
Copy link
Member

Huh, it does smell like there's a compiler bug involved then. It would be useful to get symbols and/or line-level debug info for that stack trace. 🤔

@stevapple
Copy link
Author

It's super unfortunate that stack trace on Windows doesn’t contain symbol names. Any suggestions for further debugging?

@lorentey
Copy link
Member

I haven't immediately found docs for that -- this may be worth asking about in the Windows section of the forums. Note that the assertion could be a side effect of manually adding the clang headers to the module path; it isn't necessarily relevant to the original build failure.

@stevapple
Copy link
Author

stevapple commented Aug 12, 2022

Note that the assertion could be a side effect of manually adding the clang headers to the module path; it isn't necessarily relevant to the original build failure.

I filed swiftlang/swift#60534 for this one. Will try with VS 2022 to see if anything’s different.

The original one should be triggered by missing Clang header. VS 2022 provides a stdatomics.h but that’s C++ only (so Clang prefers its own implementation), and I suspect that’s why some symbols are missing.

@stevapple
Copy link
Author

I'm going to close the issue with the following conclusions:

@lorentey
Copy link
Member

lorentey commented Apr 1, 2023

Not sure why this was closed. IIUC, the package still has problems building on Windows.

@lorentey lorentey reopened this Apr 1, 2023
@lorentey lorentey mentioned this issue Apr 1, 2023
35 tasks
@lorentey
Copy link
Member

lorentey commented Apr 1, 2023

The work in progress to eliminate _AtomicsShims would likely help with this platform, too.

@lorentey
Copy link
Member

lorentey commented Apr 1, 2023

I pieced together some workarounds from the links above in this comment:

#79 (comment)

Unfortunately building this on Windows is still failing with a JSON decoding error during -emit-module. I'm giving up on trying to make 1.1.0 work on Windows; PRs would of course be appreciated. I'd be happy to ship potential fixes in future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants