[flang-commits] [PATCH] D111394: [flang] Implement GET_ENVIRONMENT_VARIABLE(LENGTH)

Diana Picus via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Oct 8 02:51:59 PDT 2021


rovka created this revision.
rovka added reviewers: klausler, jeanPerier.
rovka added a project: Flang.
Herald added a subscriber: jdoerfert.
rovka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Search for the environment variable in the envp string passed to
ProgramStart.

This is not exactly equivalent to using std::getenv, which is used
elsewhere in the runtime. Using envp is better imo because:

1. it avoids having to create a null-terminated variable name string to

pass into std::getenv;

2. we can actually have some control over what we pass into envp before

starting the program (i.e. it can contain what's already in the
environment + anything else we might see fit to add; otoh controlling
what getenv has access to is not trivial, since there's nothing in the
standard for setting environment variables, so we'd have to use platform
specific functionalities).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111394

Files:
  flang/runtime/command.cpp
  flang/runtime/environment.cpp
  flang/runtime/environment.h
  flang/unittests/Runtime/CommandTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111394.378149.patch
Type: text/x-patch
Size: 3982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211008/0a9c000d/attachment.bin>


More information about the flang-commits mailing list