Skip to content

Commit

Permalink
LLVM: fix race condition when initializing LLVMLanguage#activeConfigu…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
steve-s committed May 14, 2021
1 parent a5ca5bd commit 4f9bc93
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ public boolean containsLibrarySource(String path) {

@Override
protected LLVMContext createContext(Env env) {
ensureActiveConfiguration(env);

Toolchain toolchain = new ToolchainImpl(activeConfiguration.getCapability(ToolchainConfig.class), this);
env.registerService(toolchain);

LLVMContext context = new LLVMContext(this, env, toolchain);
return context;
}

private synchronized void ensureActiveConfiguration(Env env) {
if (activeConfiguration == null) {
final ArrayList<ContextExtension.Key<?>> ctxExts = new ArrayList<>();
ContextExtension.Registry r = new ContextExtension.Registry() {
Expand All @@ -300,12 +310,6 @@ public <C extends ContextExtension> ContextExtension.Key<C> register(Class<C> ty
cachedLLVMMemory = activeConfiguration.getCapability(LLVMMemory.class);
contextExtensions = ctxExts.toArray(ContextExtensionKey.EMPTY);
}

Toolchain toolchain = new ToolchainImpl(activeConfiguration.getCapability(ToolchainConfig.class), this);
env.registerService(toolchain);

LLVMContext context = new LLVMContext(this, env, toolchain);
return context;
}

/**
Expand Down

0 comments on commit 4f9bc93

Please sign in to comment.