Skip to content

Commit b7c7dbd

Browse files
Revert "libc: Remove extern "C" from main declarations" (#102827)
Reverts #102825
1 parent 1b71c47 commit b7c7dbd

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "LibcGpuBenchmark.h"
22

3-
int main(int argc, char **argv, char **envp) {
3+
extern "C" int main(int argc, char **argv, char **envp) {
44
LIBC_NAMESPACE::benchmarks::Benchmark::run_benchmarks();
55
return 0;
66
}

libc/startup/gpu/amdgpu/start.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "src/stdlib/atexit.h"
1414
#include "src/stdlib/exit.h"
1515

16-
int main(int argc, char **argv, char **envp);
16+
extern "C" int main(int argc, char **argv, char **envp);
1717

1818
namespace LIBC_NAMESPACE_DECL {
1919

libc/startup/gpu/nvptx/start.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "src/stdlib/atexit.h"
1414
#include "src/stdlib/exit.h"
1515

16-
int main(int argc, char **argv, char **envp);
16+
extern "C" int main(int argc, char **argv, char **envp);
1717

1818
namespace LIBC_NAMESPACE_DECL {
1919

libc/startup/linux/do_start.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <sys/mman.h>
2121
#include <sys/syscall.h>
2222

23-
int main(int argc, char **argv, char **envp);
23+
extern "C" int main(int argc, char **argv, char **envp);
2424

2525
extern "C" {
2626
// These arrays are present in the .init_array and .fini_array sections.

libc/test/IntegrationTest/test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@
8383
// tests, then we should not need to explicitly declare/define the main
8484
// function in individual integration tests. We will not need this macro
8585
// then.
86-
#define TEST_MAIN int main
86+
#define TEST_MAIN extern "C" int main
8787

8888
#endif // LLVM_LIBC_UTILS_INTEGRATION_TEST_TEST_H

libc/test/UnitTest/LibcTestMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TestOptions parseOptions(int argc, char **argv) {
4343

4444
} // anonymous namespace
4545

46-
int main(int argc, char **argv, char **envp) {
46+
extern "C" int main(int argc, char **argv, char **envp) {
4747
LIBC_NAMESPACE::testing::argc = argc;
4848
LIBC_NAMESPACE::testing::argv = argv;
4949
LIBC_NAMESPACE::testing::envp = envp;

libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool TestGeneratorMain(llvm::raw_ostream &OS, llvm::RecordKeeper &records) {
4747

4848
OS << '\n';
4949

50-
OS << "int main() {\n";
50+
OS << "extern \"C\" int main() {\n";
5151
for (const auto &entrypoint : EntrypointNamesOption) {
5252
if (entrypoint == "errno")
5353
continue;

0 commit comments

Comments
 (0)