17 Commits

Author SHA1 Message Date
Rintaro Ishizaki
05948bcb93 [Macros] 'close' unnecessary file descriptors in plugin process
Close all the pipe file descriptors in the child process after duping
them to the standard I/O. This is not necessary but it's a good thing to
do anyway.
2025-05-14 12:54:26 -07:00
Rintaro Ishizaki
0a0e665c22 [Macros] Ensure reaping executable plugin process
rdar://126489446
2024-05-09 16:27:01 -07:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Saleem Abdulrasool
219f6eadeb Update Program.cpp 2023-09-03 18:53:24 -07:00
Saleem Abdulrasool
06ad3a75b6 AST,Basic: update support for process execution on Windows
Implement process launching on Windows to support macros.  Prefer to use
the LLVM types wherever possible.  The pipes are converted into file
descriptors as the types are internal to the process.  This allows us to
have similar paths on both sides and avoid having to drag in `Windows.h`
for the definition of `HANDLE`.  This is the core missing functionality
for Windows to support macros.
2023-09-03 10:45:03 -07:00
Erik Eckstein
564732e0fa fix an llvm::Optional deprecation warning 2023-03-06 10:35:22 +01:00
Rintaro Ishizaki
c6387a5450 [Macros] Small changes for review 2023-02-22 17:41:43 -08:00
Rintaro Ishizaki
0e31393024 [Macros] Add executable plugin support
Executable compiler plugins are programs invoked by the host compiler
and communicate with the host with IPC via standard IO (stdin/stdout.)
Each message is serialized in JSON, prefixed with a header which is a
64bit little-endian integer indicating the size of the message.

* Basic/ExecuteWithPipe: External program invocation. Lik
  llvm::sys::ExecuteNoWait() but establishing pipes to the child's
  stdin/stdout
* Basic/Sandbox: Sandboxed execution helper. Create command line
  arguments to be executed in sandbox environment (similar to SwiftPM's
  pluging sandbox)
* AST/PluginRepository: ASTContext independent plugin manager
* ASTGen/PluginHost: Communication with the plugin. Messages are
  serialized by ASTGen/LLVMJSON

rdar://101508815
2023-02-22 10:22:14 -08:00
Saleem Abdulrasool
0314bb1dc2 Basic: guard against nullptr for env
`env` is a default'ed parameter.  In some cases it may be passed a `nullptr`,
which is not a valid parameter to `llvm::toStringRefArray`.  Guard against this
case.  This allows the swift compiler to work again on Windows!
2018-09-04 11:48:51 -07:00
Saleem Abdulrasool
dd0dd7b2d1 Basic: update the use of the ExecuteNoWait API
This now takes `ArrayRef<StringRef>` and `Optional<ArrayRef<StringRef>>`
parameters.  Explicitly update the interfaces to match.  This is particularly
important to repair the Windows build.
2018-08-22 15:34:29 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Connor Wakamo
cec27abeb8 Adjust ExecuteInPlace() so that it calls exit() on success on platforms where native re-execution is not implemented.
Swift SVN r12606
2014-01-20 19:26:49 +00:00
Connor Wakamo
ab2172cc97 [driver] Added support for executing a single Command without a TaskQueue.
Added swift::ExecuteInPlace(), which on Unix acts as a wrapper for execv()
and execve(). On other platforms, swift::ExecuteInPlace() is a wrapper for
llvm::sys::ExecuteAndWait(), so callers must be prepared for ExecuteInPlace()
to return in a non-error situation.

Added support in Compilation::performJobs() to detect that the Compilation has
exactly one Command to run. If that's the case, and buffered output isn't
required, execute that Command using swift::ExecuteInPlace() (instead of
creating a TaskQueue, which may unconditionally buffer output).

This change will allow the driver to invoke the frontend's REPL and immediate
modes without buffering output (and, on Unix, without a separate process being
spawned).

Also updated test/Driver/basic.swift to emit output with these changes in place.

Swift SVN r12544
2014-01-18 20:55:18 +00:00