Skip to content

Commit 44f3d7c

Browse files
authored
Merge pull request #22189 from JuliaLang/vc/win_libatomic
Install and use libatomic on windows.
2 parents 7c045f0 + eca1f1e commit 44f3d7c

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ $(eval $(call std_dll,gcc_s_seh-1))
323323
endif
324324
$(eval $(call std_dll,ssp-0))
325325
$(eval $(call std_dll,winpthread-1))
326+
$(eval $(call std_dll,atomic-1))
326327
endif
327328
define stringreplace
328329
$(build_depsbindir)/stringreplace $$(strings -t x - $1 | grep '$2' | awk '{print $$1;}') '$3' 255 "$(call cygpath_w,$1)"

src/jitlayers.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,17 @@ void NotifyDebugger(jit_code_entry *JITCodeEntry)
316316
}
317317
// ------------------------ END OF TEMPORARY COPY FROM LLVM -----------------
318318

319-
#if defined(_OS_LINUX_)
319+
#if defined(_OS_LINUX_) || defined(_OS_WINDOWS_)
320320
// Resolve non-lock free atomic functions in the libatomic library.
321321
// This is the library that provides support for c11/c++11 atomic operations.
322322
static uint64_t resolve_atomic(const char *name)
323323
{
324-
static void *atomic_hdl = jl_load_dynamic_library_e("libatomic",
324+
#if defined(_OS_LINUX_)
325+
static const char *const libatomic = "libatomic";
326+
#elif defined(_OS_WINDOWS_)
327+
static const char *const libatomic = "libatomic-1";
328+
#endif
329+
static void *atomic_hdl = jl_load_dynamic_library_e(libatomic,
325330
JL_RTLD_LOCAL);
326331
static const char *const atomic_prefix = "__atomic_";
327332
if (!atomic_hdl)
@@ -534,7 +539,7 @@ void JuliaOJIT::addModule(std::unique_ptr<Module> M)
534539
// Step 2: Search the program symbols
535540
if (uint64_t addr = SectionMemoryManager::getSymbolAddressInProcess(Name))
536541
return JL_SymbolInfo(addr, JITSymbolFlags::Exported);
537-
#if defined(_OS_LINUX_)
542+
#if defined(_OS_LINUX_) || defined(_OS_WINDOWS_)
538543
if (uint64_t addr = resolve_atomic(Name.c_str()))
539544
return JL_SymbolInfo(addr, JITSymbolFlags::Exported);
540545
#endif

src/julia_internal.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,9 @@ void gc_sweep_sysimg(void);
155155
static const int jl_gc_sizeclasses[JL_GC_N_POOLS] = {
156156
#ifdef _P64
157157
8,
158-
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_) || defined(_CPU_X86_)
158+
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_)
159159
// ARM and PowerPC have max alignment of 8,
160160
// make sure allocation of size 8 has that alignment.
161-
// for x86 alignment is important for atomic ops and
162-
// the corresponding platform ABI. Once we can use
163-
// libatomic on Windows this is no longer necessary.
164161
4, 8,
165162
#else
166163
4, 8, 12,
@@ -196,7 +193,7 @@ STATIC_INLINE int jl_gc_alignment(size_t sz)
196193
#ifdef _P64
197194
(void)sz;
198195
return 16;
199-
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_) || defined(_CPU_X86_)
196+
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_)
200197
return sz <= 4 ? 8 : 16;
201198
#else
202199
// szclass 8
@@ -217,7 +214,7 @@ STATIC_INLINE int JL_CONST_FUNC jl_gc_szclass(size_t sz)
217214
if (sz <= 8)
218215
return 0;
219216
const int N = 0;
220-
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_) || defined(_CPU_X86_)
217+
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_)
221218
if (sz <= 8)
222219
return (sz + 3) / 4 - 1;
223220
const int N = 1;

src/julia_threads.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef struct {
6262
// variables for allocating objects from pools
6363
#ifdef _P64
6464
# define JL_GC_N_POOLS 41
65-
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_) || defined(_CPU_X86_)
65+
#elif defined(_CPU_ARM_) || defined(_CPU_PPC_)
6666
# define JL_GC_N_POOLS 42
6767
#else
6868
# define JL_GC_N_POOLS 43

0 commit comments

Comments
 (0)