This is an archive of the discontinued LLVM Phabricator instance.

[z/OS][pg] Throw error when using -pg on z/OS
ClosedPublic

Authored by francii on Nov 9 2022, 6:07 PM.

Details

Summary

Throw an error when trying to compile with -pg on z/OS,
as the platform does not support gprof.

Diff Detail

Event Timeline

francii created this revision.Nov 9 2022, 6:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 6:07 PM
francii requested review of this revision.Nov 9 2022, 6:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 6:07 PM
francii edited the summary of this revision. (Show Details)Nov 9 2022, 6:17 PM
francii edited the summary of this revision. (Show Details)Nov 9 2022, 8:39 PM
SeanP added a subscriber: SeanP.Nov 9 2022, 9:17 PM
SeanP added inline comments.
clang/include/clang/Basic/DiagnosticDriverKinds.td
241 ↗(On Diff #474406)

Rather than saying "on z/OS" you should say "by the target '%1'" and pass in the triple. There must be the equivalent message already. If not rename the message too (eg. err_option_unsupported_target).

francii updated this revision to Diff 474440.Nov 9 2022, 9:51 PM

Use existing error

This comment was removed by francii.
clang/test/Driver/zos-profiling-error.c
8

I will add the missing e in error: momentarily.

francii updated this revision to Diff 477241.Nov 22 2022, 10:04 AM

Fix test case

cebowleratibm accepted this revision.Nov 30 2022, 6:40 AM
This revision is now accepted and ready to land.Nov 30 2022, 6:40 AM
MaskRay added inline comments.Dec 2 2022, 11:01 AM
clang/test/Driver/zos-profiling-error.c
4

Prefer --target= for new tests. Consider reusing clang/test/Driver/p.c and adding the code to clang/lib/Driver/ToolChains/Clang.cpp instead

MaskRay requested changes to this revision.Dec 2 2022, 11:03 AM
MaskRay added inline comments.
clang/test/Driver/zos-profiling-error.c
4

Sorry, the code is not needed since clang/lib/Driver/ToolChains/Clang.cpp rejects -p for most OSes now.

This revision now requires changes to proceed.Dec 2 2022, 11:03 AM
francii updated this revision to Diff 480130.Dec 5 2022, 8:48 AM
francii marked an inline comment as not done.

Remove -p references

MaskRay added a comment.EditedDec 5 2022, 12:07 PM

See clang/lib/Driver/ToolChains/Clang.cpp:6191 if (TC.SupportsProfiling()) {. You can define SupportsProfiling as false for zos. It's a -Wunused-command-line-argument warning, not an error, but may be good enough.

-p has already been handled, so the subject Throw Error When Using -p or -pg on z/OS should be updated. Note that we don't capitalize every word, just the first word.

francii retitled this revision from [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS to [z/OS][pg] Throw Error When Using -p or -pg on z/OS.Dec 5 2022, 4:40 PM
francii edited the summary of this revision. (Show Details)Dec 26 2022, 4:44 PM
francii retitled this revision from [z/OS][pg] Throw Error When Using -p or -pg on z/OS to [z/OS][pg] Throw error when using -pg on z/OS.Dec 26 2022, 4:47 PM
MaskRay requested changes to this revision.Dec 28 2022, 11:08 AM

Most targets reject -p now. It's unnecessary to have another z/OS specific diagnostic. So this patch can be abandoned.

% fclang -p a.cc
clang-16: error: unsupported option '-p' for target 'x86_64-unknown-linux-gnu'
This revision now requires changes to proceed.Dec 28 2022, 11:08 AM

Most targets reject -p now. It's unnecessary to have another z/OS specific diagnostic. So this patch can be abandoned.

% fclang -p a.cc
clang-16: error: unsupported option '-p' for target 'x86_64-unknown-linux-gnu'

@francii, if you can confirm:

  1. that there is a test that covers that error for z/OS, and
  2. any comments in the code associated with generating the error above do not misrepresent the rationale for why -p is unsupported on z/OS,

then I'm good with leaving it at that.

Otherwise, we should make this into an NFC patch that adds the test/adjusts the comments.

Most targets reject -p now. It's unnecessary to have another z/OS specific diagnostic. So this patch can be abandoned.

% fclang -p a.cc
clang-16: error: unsupported option '-p' for target 'x86_64-unknown-linux-gnu'

@francii, if you can confirm:

  1. that there is a test that covers that error for z/OS, and
  2. any comments in the code associated with generating the error above do not misrepresent the rationale for why -p is unsupported on z/OS,

then I'm good with leaving it at that.

Otherwise, we should make this into an NFC patch that adds the test/adjusts the comments.

  1. There is no test for z/OS. clang/test/Driver/p.c exists but does not contain a z/OS test case.
  2. There are no comments explaining why -p is unsupported. Removing support for -p came with D138255, which simply states that -p is only supported on AIX and OpenBSD.
francii added inline comments.Jan 4 2023, 12:03 PM
clang/lib/Driver/ToolChains/ZOS.cpp
22 ↗(On Diff #480130)

@MaskRay we still need -pg to error-out on z/OS. Should the check for this be moved to clang/lib/Driver/ToolChains/Clang.cpp instead?

MaskRay added inline comments.Jan 4 2023, 2:19 PM
clang/lib/Driver/ToolChains/ZOS.cpp
22 ↗(On Diff #480130)

Sounds reasonable to move -pg diagnostic beside -p.

francii updated this revision to Diff 493401.Jan 30 2023, 1:37 PM

Move check to Clang.cpp

MaskRay accepted this revision.Feb 6 2023, 1:15 PM

Thanks!

clang/test/Driver/zos-profiling-error.c
2

Delete this comment. It does not help reading the test.

4

Use --target=

-target is legacy.

This revision is now accepted and ready to land.Feb 6 2023, 1:15 PM
francii updated this revision to Diff 495267.Feb 6 2023, 1:50 PM

Rebase and test case update

francii updated this revision to Diff 495570.Feb 7 2023, 9:04 AM

Update test case verbosity

This revision was automatically updated to reflect the committed changes.