-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e2aac6
commit 885d0eb
Showing
14 changed files
with
1,148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc | ||
index 8f8f15685f..a7ae52d1e4 100644 | ||
--- a/src/main/cpp/option_processor.cc | ||
+++ b/src/main/cpp/option_processor.cc | ||
@@ -56,7 +56,7 @@ OptionProcessor::OptionProcessor( | ||
: workspace_layout_(workspace_layout), | ||
startup_options_(std::move(default_startup_options)), | ||
parse_options_called_(false), | ||
- system_bazelrc_path_(BAZEL_SYSTEM_BAZELRC_PATH) {} | ||
+ system_bazelrc_path_("@bazelSystemBazelRCPath@") {} | ||
|
||
OptionProcessor::OptionProcessor( | ||
const WorkspaceLayout* workspace_layout, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.google.devtools.build.lib.runtime; | ||
|
||
// We only need to capture enough details from Bazel source code | ||
// to make our modules compile and be binary-compatible. | ||
// This BlazeModule won't be injected into Bazel classpath. | ||
public abstract class BlazeModule { | ||
} |
9 changes: 9 additions & 0 deletions
9
pkgs/by-name/ba/bazel_8/darwin_hacks/SleepPreventionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.google.devtools.build.lib.platform; | ||
|
||
import com.google.devtools.build.lib.runtime.BlazeModule; | ||
|
||
// This class can fail in Nix sandbox on Darwin so we replace | ||
// it with a stub version | ||
public final class SleepPreventionModule extends BlazeModule { | ||
// do nothing | ||
} |
15 changes: 15 additions & 0 deletions
15
pkgs/by-name/ba/bazel_8/darwin_hacks/SystemSuspensionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.google.devtools.build.lib.platform; | ||
|
||
import com.google.devtools.build.lib.runtime.BlazeModule; | ||
|
||
// This class can fail in Nix sandbox on Darwin so we replace | ||
// it with a stub version | ||
public final class SystemSuspensionModule extends BlazeModule { | ||
// do nothing | ||
|
||
// this method is part of module interface | ||
synchronized void suspendCallback(int reason) { | ||
// do nothing | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
stdenv, | ||
buildJdk, | ||
runJdk, | ||
version, | ||
writeScript, | ||
}: | ||
let | ||
fakeBazelModules = stdenv.mkDerivation { | ||
pname = "fakeBazelModules"; | ||
inherit version; | ||
dontUnpack = true; | ||
buildPhase = " | ||
# Java file name needs to match class name so we need to copy | ||
cp ${./BlazeModule.java} ./BlazeModule.java | ||
cp ${./SystemSuspensionModule.java} ./SystemSuspensionModule.java | ||
cp ${./SleepPreventionModule.java} ./SleepPreventionModule.java | ||
# compile all sources | ||
${buildJdk}/bin/javac -d . BlazeModule.java SystemSuspensionModule.java SleepPreventionModule.java | ||
# don't package BlazeModule.class as we want to use real base class, but a stub compatible version was needed to make | ||
# fake modules compile | ||
${buildJdk}/bin/jar cf output.jar ./com/google/devtools/build/lib/platform/{SystemSuspension,SleepPrevention}Module.class | ||
"; | ||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/ | ||
install -Dm755 output.jar $out/output.jar | ||
runHook postInstall | ||
''; | ||
|
||
}; | ||
# bin/java wrapper that injects fake modules into classpath | ||
jvmInterceptSh = writeScript "java" '' | ||
#!/usr/bin/env bash | ||
# replaces | ||
# .. -jar foo.jar .. | ||
# with | ||
# .. -cp ..overrides..:foo.jar MainClass .. | ||
# to inject fake modules classes into Bazel | ||
for (( i=2; i <= "$#"; i++ )); do | ||
if [[ "''${!i}" == "-jar" ]]; then | ||
prev=$(( i - 1 )) | ||
jar=$(( i + 1 )) | ||
MAIN_CLASS=$(unzip -qc "''${!jar}" META-INF/MANIFEST.MF | grep "^Main-Class: " | cut -d " " -f 2- | tr -d "\r") | ||
next=$(( jar + 1 )) | ||
exec "${runJdk}/bin/java" "''${@:1:prev}" -cp "${fakeBazelModules}/output.jar:''${!jar}" "$MAIN_CLASS" "''${@:next}" | ||
fi | ||
done | ||
echo "Failed to find -jar argument in: $@" >&2 | ||
exit 1 | ||
''; | ||
in | ||
{ | ||
jvmIntercept = stdenv.mkDerivation { | ||
pname = "jvmIntercept"; | ||
inherit version; | ||
dontUnpack = true; | ||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/bin | ||
install -Dm755 ${jvmInterceptSh} $out/bin/java | ||
runHook postInstall | ||
''; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
diff --git a/src/main/native/darwin/sleep_prevention_jni.cc b/src/main/native/darwin/sleep_prevention_jni.cc | ||
index 67c35b201e..e50a58320e 100644 | ||
--- a/src/main/native/darwin/sleep_prevention_jni.cc | ||
+++ b/src/main/native/darwin/sleep_prevention_jni.cc | ||
@@ -33,31 +33,13 @@ static int g_sleep_state_stack = 0; | ||
static IOPMAssertionID g_sleep_state_assertion = kIOPMNullAssertionID; | ||
|
||
int portable_push_disable_sleep() { | ||
- std::lock_guard<std::mutex> lock(g_sleep_state_mutex); | ||
- BAZEL_CHECK_GE(g_sleep_state_stack, 0); | ||
- if (g_sleep_state_stack == 0) { | ||
- BAZEL_CHECK_EQ(g_sleep_state_assertion, kIOPMNullAssertionID); | ||
- CFStringRef reasonForActivity = CFSTR("build.bazel"); | ||
- IOReturn success = IOPMAssertionCreateWithName( | ||
- kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, | ||
- &g_sleep_state_assertion); | ||
- BAZEL_CHECK_EQ(success, kIOReturnSuccess); | ||
- } | ||
- g_sleep_state_stack += 1; | ||
- return 0; | ||
+ // Unreliable, disable for now | ||
+ return -1; | ||
} | ||
|
||
int portable_pop_disable_sleep() { | ||
- std::lock_guard<std::mutex> lock(g_sleep_state_mutex); | ||
- BAZEL_CHECK_GT(g_sleep_state_stack, 0); | ||
- g_sleep_state_stack -= 1; | ||
- if (g_sleep_state_stack == 0) { | ||
- BAZEL_CHECK_NE(g_sleep_state_assertion, kIOPMNullAssertionID); | ||
- IOReturn success = IOPMAssertionRelease(g_sleep_state_assertion); | ||
- BAZEL_CHECK_EQ(success, kIOReturnSuccess); | ||
- g_sleep_state_assertion = kIOPMNullAssertionID; | ||
- } | ||
- return 0; | ||
+ // Unreliable, disable for now | ||
+ return -1; | ||
} | ||
|
||
} // namespace blaze_jni | ||
diff --git a/src/main/native/darwin/system_suspension_monitor_jni.cc b/src/main/native/darwin/system_suspension_monitor_jni.cc | ||
index 3483aa7935..51782986ec 100644 | ||
--- a/src/main/native/darwin/system_suspension_monitor_jni.cc | ||
+++ b/src/main/native/darwin/system_suspension_monitor_jni.cc | ||
@@ -83,10 +83,7 @@ void portable_start_suspend_monitoring() { | ||
// Register to receive system sleep notifications. | ||
// Testing needs to be done manually. Use the logging to verify | ||
// that sleeps are being caught here. | ||
- suspend_state.connect_port = IORegisterForSystemPower( | ||
- &suspend_state, ¬ifyPortRef, SleepCallBack, ¬ifierObject); | ||
- BAZEL_CHECK_NE(suspend_state.connect_port, MACH_PORT_NULL); | ||
- IONotificationPortSetDispatchQueue(notifyPortRef, queue); | ||
+ // XXX: Unreliable, disable for now | ||
|
||
// Register to deal with SIGCONT. | ||
// We register for SIGCONT because we can't catch SIGSTOP. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools | ||
index a8af76e90c..7f8b030f63 100644 | ||
--- a/tools/jdk/BUILD.tools | ||
+++ b/tools/jdk/BUILD.tools | ||
@@ -146,6 +146,25 @@ py_test( | ||
], | ||
) | ||
|
||
+##### Nonprebuilt toolchains definitions for NixOS and nix build sandboxes #### | ||
+ | ||
+load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain", "NONPREBUILT_TOOLCHAIN_CONFIGURATION") | ||
+ | ||
+[ | ||
+ default_java_toolchain( | ||
+ name = "nonprebuilt_toolchain_java" + str(version), | ||
+ configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION, | ||
+ java_runtime = "@local_jdk//:jdk", | ||
+ source_version = str(version), | ||
+ target_version = str(version), | ||
+ ) | ||
+ # Ideally we would only define toolchains for the java versions that the | ||
+ # local jdk supports. But we cannot access this information in a BUILD | ||
+ # file, and this is a hack anyway, so just pick a large enough upper bound. | ||
+ # At the current pace, java <= 30 should cover all realeases until 2028. | ||
+ for version in range(8, 31) | ||
+] | ||
+ | ||
#### Aliases to rules_java to keep backward-compatibility (begin) #### | ||
|
||
TARGET_NAMES = [ |
47 changes: 47 additions & 0 deletions
47
pkgs/by-name/ba/bazel_8/nix-build-bazel-package-hacks.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java | ||
index 53e6494656..22261cd268 100644 | ||
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java | ||
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java | ||
@@ -55,6 +55,7 @@ import com.google.devtools.build.skyframe.SkyFunctionException.Transience; | ||
import com.google.devtools.build.skyframe.SkyKey; | ||
import com.google.devtools.build.skyframe.SkyValue; | ||
import java.io.IOException; | ||
+import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.TreeMap; | ||
@@ -193,16 +194,11 @@ public final class RepositoryDelegatorFunction implements SkyFunction { | ||
} | ||
|
||
if (shouldUseCachedRepos(env, handler, repoRoot, rule)) { | ||
- // Make sure marker file is up-to-date; correctly describes the current repository state | ||
- byte[] markerHash = digestWriter.areRepositoryAndMarkerFileConsistent(handler, env); | ||
- if (env.valuesMissing()) { | ||
- return null; | ||
- } | ||
- if (markerHash != null) { // repo exist & up-to-date | ||
+ { | ||
+ // Nix hack: Always consider cached dirs as up-to-date | ||
return RepositoryDirectoryValue.builder() | ||
.setPath(repoRoot) | ||
- .setDigest(markerHash) | ||
- .setExcludeFromVendoring(excludeRepoFromVendoring) | ||
+ .setDigest(digestWriter.writeMarkerFile(Collections.emptyMap())) | ||
.build(); | ||
} | ||
} | ||
|
||
|
||
diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java | ||
index 649647c5f2..64d05b530c 100644 | ||
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java | ||
+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java | ||
@@ -158,7 +158,6 @@ public class JavaSubprocessFactory implements SubprocessFactory { | ||
ProcessBuilder builder = new ProcessBuilder(); | ||
builder.command(Lists.transform(params.getArgv(), StringEncoding::internalToPlatform)); | ||
if (params.getEnv() != null) { | ||
- builder.environment().clear(); | ||
params | ||
.getEnv() | ||
.forEach( | ||
|
Oops, something went wrong.