[PATCH] D105896: [flang][driver] Fix output filename generation in `flang`
Andrzej Warzynski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 01:00:48 PDT 2021
awarzynski added inline comments.
================
Comment at: flang/tools/f18/flang.in:337
for idx in "${!fortran_source_files[@]}"; do
- if ! "$wd/bin/@FLANG_DEFAULT_DRIVER@" "${flang_options[@]}" "${fortran_source_files[$idx]}" -o "${unparsed_file}_${idx}.f90"
- then status=$?
- echo flang: in "$PWD", @FLANG_DEFAULT_DRIVER@ failed with exit status $status: "$wd/bin/@FLANG_DEFAULT_DRIVER@" "${flang_options[@]}" "$@" >&2
- exit $status
+ "$wd/bin/@FLANG_DEFAULT_DRIVER@" "${flang_options[@]}" "${fortran_source_files[$idx]}" -o "${unparsed_file}_${idx}.f90"
+ ret_status=$?
----------------
DavidSpickett wrote:
> I'm surprised that this works with:
> ```
> set -euo pipefail
> ```
>
> (but then again bash is always surprising)
That's a great catch, thank you!
I don't see a better way to work around it other than surrounding such statements with `set +e` and `set -e`. That's also the suggested solution [[ http://redsymbol.net/articles/unofficial-bash-strict-mode/#expect-nonzero-exit-status | here ]] (it's the best intro into `set -euo pipefail` that I am aware of). This is not great, but we don't consider this script a long-term solution, so perhaps that's fine?
As for `if ! <command>`, that sets `$?` to `0` when `<command>` fails. That's because there is `!` in `! <command>`. This is not what we want here. This is documented in `help if`. Hence the need to update this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105896/new/
https://reviews.llvm.org/D105896
More information about the llvm-commits
mailing list