Skip to content

Commit b72b45d

Browse files
committed
CLJCLR-166 loading of core.clj and related should use direct linking
1 parent 27a5a70 commit b72b45d

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

Clojure/Clojure/CljCompiler/Compiler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public static object GetCompilerOption(Keyword k)
205205
return RT.get(CompilerOptionsVar.deref(), k);
206206
}
207207

208-
static void InitializeCompilerOptions()
208+
internal static void InitializeCompilerOptions()
209209
{
210210
Object compilerOptions = null;
211211

@@ -469,7 +469,8 @@ static Compiler()
469469
Methods_IFn_invoke[Compiler.MaxPositionalArity + 1]
470470
= typeof(IFn).GetMethod("invoke", types);
471471

472-
InitializeCompilerOptions();
472+
// Moved this to clojure.lang.RT's static constructor because we need to bind *compiler-options* there.
473+
// InitializeCompilerOptions();
473474
}
474475

475476
#endregion

Clojure/Clojure/Lib/RT.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,25 @@ static RT()
442442
// this is okay. It just means that the assets clojure/core.clj and company are going to be somewhere else
443443
}
444444

445+
// Moved the intiailization of *compiler-options* from the clojure.lang.Compiler static constructor to here.
446+
// We need to make sure direct linking is turned on for this load (and later on for the load of the spec files)
447+
448+
Compiler.InitializeCompilerOptions();
449+
445450
if (RuntimeBootstrapFlag._doRTBootstrap)
446-
load("clojure/core");
451+
{
452+
var optionsMapToUse = (Associative)Compiler.CompilerOptionsVar.deref() ?? PersistentHashMap.EMPTY;
453+
Var.pushThreadBindings(RT.map(Compiler.CompilerOptionsVar, optionsMapToUse.assoc(Compiler.DirectLinkingKeyword, true)));
454+
455+
try
456+
{
457+
load("clojure/core");
458+
}
459+
finally
460+
{
461+
Var.popThreadBindings();
462+
}
463+
}
447464
}
448465

449466
public static void LoadSpecCode()
@@ -478,12 +495,20 @@ static void DoInit()
478495

479496

480497
// load spec
498+
var optionsMapToUse = (Associative)Compiler.CompilerOptionsVar.deref() ?? PersistentHashMap.EMPTY;
499+
Var.pushThreadBindings(RT.map(Compiler.CompilerOptionsVar, optionsMapToUse.assoc(Compiler.DirectLinkingKeyword, true)));
500+
501+
try
481502
{
482503
string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
483504

484505
Assembly.LoadFile(Path.Combine(baseDir, "clojure.spec.alpha.dll"));
485506
Assembly.LoadFile(Path.Combine(baseDir, "clojure.core.specs.alpha.dll"));
486507
}
508+
finally
509+
{
510+
Var.popThreadBindings();
511+
}
487512

488513
PostBootstrapInit();
489514

0 commit comments

Comments
 (0)