Skip to content

[stdlib] Set PYTHONIOENCODING when building the stdlib #68218

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 3 commits into from
Aug 31, 2023
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
7 changes: 4 additions & 3 deletions stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ function(_compile_swift_files
set(swift_compiler_tool "${SWIFT_SOURCE_DIR}/utils/check-incremental" "${swift_compiler_tool}")
endif()

set(custom_env "PYTHONIOENCODING=UTF8")
if(SWIFTFILE_IS_STDLIB OR
# Linux "hosttools" build require builder's runtime before building the runtime.
(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
Expand All @@ -811,13 +812,13 @@ function(_compile_swift_files
# to pick up the stdlib from the previous bootstrapping stage, because the
# stdlib in the current stage is not built yet.
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
set(set_environment_args "${CMAKE_COMMAND}" "-E" "env" "DYLD_LIBRARY_PATH=${bs_lib_dir}")
list(APPEND custom_env "DYLD_LIBRARY_PATH=${bs_lib_dir}")
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
set(set_environment_args "${CMAKE_COMMAND}" "-E" "env" "LD_LIBRARY_PATH=${bs_lib_dir}")
list(APPEND custom_env "LD_LIBRARY_PATH=${bs_lib_dir}")
endif()
endif()

endif()
set(set_environment_args "${CMAKE_COMMAND}" "-E" "env" "${custom_env}")

if (SWIFT_REPORT_STATISTICS)
list(GET dirs_to_create 0 first_obj_dir)
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/unicode_filename.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: %target-swift-frontend -scan-dependencies %/s %/S/Inputs/unicode_filёnamё.swift -o %t/deps.json

// Check the contents of the JSON output
// RUN: env PYTHONIOENCODING=UTF-8 %validate-json < %t/deps.json
// RUN: %validate-json < %t/deps.json
// RUN: %FileCheck %s < %t/deps.json

public func bar() {
Expand Down
8 changes: 6 additions & 2 deletions validation-test/Python/line-directive.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// REQUIRES: rdar92613094
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// RUN: %{python} %utils/line-directive
// RUN: %{python} %utils/line-directive -- %{python} -c "print('你好')"
// RUN: %{python} %utils/line-directive -- %{python} %t/unicode.py

//--- unicode.py
print('你好')