Skip to content

Commit

Permalink
Added a registry key to disable passing the extra compiler flags to B…
Browse files Browse the repository at this point in the history
…azel when building a C/C++ target in debug mode.
  • Loading branch information
odisseus committed Jun 5, 2023
1 parent a65a9a3 commit 5e66622
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions clwb/src/META-INF/clwb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<moduleType id="BLAZE_CPP_MODULE" implementationClass="com.google.idea.blaze.clwb.BlazeCppModuleType"/>
<postStartupActivity implementation="com.google.idea.blaze.clwb.run.producers.NonBlazeProducerSuppressor"/>
<actionConfigurationCustomizer implementation="com.google.idea.blaze.plugin.ClwbHideMakeActions"/>
<registryKey defaultValue="false" description="Disable the extra debug flags in debug C/C++ builds" key="bazel.clwb.debug.extraflags.disabled"/>
</extensions>

<extensions defaultExtensionNs="cidr.debugger">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.intellij.util.PathUtil;
import com.jetbrains.cidr.execution.CidrCommandLineState;

import java.util.Collections;
import javax.annotation.Nullable;
import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -112,25 +113,28 @@ private File getExecutableToDebug(ExecutionEnvironment env) throws ExecutionExce
try (BuildResultHelper buildResultHelper =
BuildResultHelperProvider.createForLocalBuild(env.getProject())) {

List<String> extraDebugFlags;
if (!BlazeGDBServerProvider.shouldUseGdbserver()) {
ImmutableList<String> extraClangFlags = isClangBuild() && !Registry.is("bazel.trim.absolute.path.disabled")
? ImmutableList.of(
"--copt=-fdebug-compilation-dir=" + WorkspaceRoot.fromProject(env.getProject()),
"--linkopt=-Wl,-oso_prefix,.")
: ImmutableList.of();
extraDebugFlags =
Streams.concat(
Stream.of(
"--compilation_mode=dbg",
"--copt=-O0",
"--copt=-g",
"--strip=never",
"--dynamic_mode=off",
"--fission=yes"), extraClangFlags.stream()).collect(Collectors.toList());
} else {
extraDebugFlags =
BlazeGDBServerProvider.getFlagsForDebugging(configuration.getHandler().getState());
List<String> extraDebugFlags = Collections.emptyList();
if(!Registry.is("bazel.clwb.debug.extraflags.disabled")) {
if (!BlazeGDBServerProvider.shouldUseGdbserver()) {
ImmutableList<String> extraClangFlags =
isClangBuild() && !Registry.is("bazel.trim.absolute.path.disabled")
? ImmutableList.of(
"--copt=-fdebug-compilation-dir=" + WorkspaceRoot.fromProject(env.getProject()),
"--linkopt=-Wl,-oso_prefix,.")
: ImmutableList.of();
extraDebugFlags =
Streams.concat(
Stream.of(
"--compilation_mode=dbg",
"--copt=-O0",
"--copt=-g",
"--strip=never",
"--dynamic_mode=off",
"--fission=yes"), extraClangFlags.stream()).collect(Collectors.toList());
} else {
extraDebugFlags =
BlazeGDBServerProvider.getFlagsForDebugging(configuration.getHandler().getState());
}
}

ListenableFuture<BuildResult> buildOperation =
Expand Down

0 comments on commit 5e66622

Please sign in to comment.