Skip to content

[embedded] Fix linux-rng-support.c compiling in C++ mode, make it C instead #80617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions test/embedded/Inputs/linux-rng-support.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@

#ifdef __linux__

#ifdef __cplusplus
extern "C"
#endif
ssize_t getrandom(void *buf, size_t len, unsigned int flags);

#ifdef __cplusplus
extern "C"
#endif
void arc4random_buf(void *buf, size_t nbytes);

void arc4random_buf(void *buf, size_t nbytes) {
Expand Down
2 changes: 1 addition & 1 deletion test/embedded/linkage-mergeable4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// RUN: %target-swift-frontend -mergeable-symbols -num-threads 2 -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -mergeable-symbols -num-threads 2 -O -c -o %t/MainA.o -o %t/MainB.o %t/MainA.swift %t/MainB.swift -I %t -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-clang %linux_rng_support_c_if_needed %t/MainA.o %t/MainB.o %t/MyModule.o -o %t/a.out
// RUN: %target-embedded-link %t/MainA.o %t/MainB.o %t/MyModule.o -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s

// REQUIRES: swift_in_compiler
Expand Down
5 changes: 3 additions & 2 deletions test/embedded/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config.substitutions = list(config.substitutions)
# A handful of test setup tweaks that we want for *all* Embedded Swift tests (i.e. all tests in this directory):

# (1) When targeting macOS, raise the deployment target to macOS 14.0 (from the default 13.0)
config.target_clang = config.target_clang.replace("-apple-macosx13.0", "-apple-macos14")
if config.target_sdk_name == 'macosx':
def do_fixup(key, value):
if isinstance(value, str):
Expand Down Expand Up @@ -31,6 +32,6 @@ if 'SWIFT_AVOID_WARNING_USING_OLD_DRIVER' in config.environment: del config.envi

# (5) Provide some useful substitutions to simplify writing tests that work across platforms (macOS, Linux, etc.)
if "OS=linux-gnu" in config.available_features:
config.substitutions.append(("%linux_rng_support_c_if_needed", "%S/Inputs/linux-rng-support.c"))
config.substitutions.append(("%target-embedded-link", config.target_clang + " -x c %S/Inputs/linux-rng-support.c -x none"))
else:
config.substitutions.append(("%linux_rng_support_c_if_needed", ""))
config.substitutions.append(("%target-embedded-link", config.target_clang))