Skip to content

Commit 80ab94f

Browse files
Fix stub linker error (youtube#5558)
b/413130400 Add warning override as the compiler correctly detects code which is unreachable as COBALT_LINKER_STUB is supposed to crash in devel builds. Ensure that the stub method doesnt trigger a crash in prod builds. Add include gaurds to the linker_stub.h header file
1 parent 958331f commit 80ab94f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

base/BUILD.gn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,7 @@ component("base") {
17601760
"process/process_metrics_posix_starboard_stub.cc",
17611761
"starboard/linker_stub.h"
17621762
]
1763+
all_dependent_configs += [ ":base_starboard_linker_stub" ]
17631764
}
17641765

17651766
if (is_cobalt && enable_cobalt_hermetic_hacks) {
@@ -5033,3 +5034,11 @@ source_set("partition_alloc_test_support") {
50335034
configs += [ "//build/config/compiler:optimize_speed" ]
50345035
}
50355036
}
5037+
5038+
if (is_cobalt_hermetic_build) {
5039+
# TODO: b/413130400 - Cobalt: Remove this config
5040+
# after removing base/starboard/linker_stub.h
5041+
config("base_starboard_linker_stub") {
5042+
cflags = ["-Wno-unreachable-code-break"]
5043+
}
5044+
}

base/starboard/linker_stub.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#ifndef BASE_STARBOARD_LINKER_STUB_H_
16+
#define BASE_STARBOARD_LINKER_STUB_H_
17+
1518
#include "starboard/common/log.h"
1619

1720
// TODO: b/413130400 - Cobalt: Remove this file and implement linker stubs
1821

22+
#if BUILDFLAG(COBALT_IS_RELEASE_BUILD)
23+
#define COBALT_LINKER_STUB()
24+
#else
1925
#define COBALT_LINKER_STUB_MSG \
2026
"This is a stub needed for linking cobalt. You need to remove " \
2127
"COBALT_LINKER_STUB and implement " \
@@ -29,3 +35,6 @@
2935
} \
3036
} while (0); \
3137
SbSystemBreakIntoDebugger();
38+
#endif // BUILDFLAG(COBALT_IS_RELEASE_BUILD)
39+
40+
#endif // BASE_STARBOARD_LINKER_STUB_H_

0 commit comments

Comments
 (0)