https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106302
Bug ID: 106302 Summary: RFE: provide a way for -fanalyzer to use target flags Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Blocks: 106003, 106301 Target Milestone: --- As noted in the discussion here: https://gcc.gnu.org/pipermail/gcc/2022-June/238954.html -fanalyzer sometimes uses specific target flags when modeling the behavior of functions, see e.g.: sm-fd.cc, which currently has: enum access_mode fd_state_machine::get_access_mode_from_flag (int flag) const { /* FIXME: this code assumes the access modes on the host and target are the same, which in practice might not be the case. */ if ((flag & O_ACCMODE) == O_RDONLY) { return READ_ONLY; } else if ((flag & O_ACCMODE) == O_WRONLY) { return WRITE_ONLY; } return READ_WRITE; } where we are using the values of O_ACCMODE, O_RDONLY, and O_WRONLY from the host's headers, rather than those of the target. See also bug 106301, where properly supporting mmap would mean looking at values of MAP_ANONYMOUS, and of the various PROT_ values. Joseph suggested adding a target hook for this, though I think we'd need an enum for it, so that we can add various different "well known" values that we'd want to query for on the host. Alternatively, perhaps we could directly query the preprocessor somehow, though that wouldn't work for the LTO case. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106003 [Bug 106003] RFE: -fanalyzer could complain about misuse of file-descriptors https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106301 [Bug 106301] RFE: analyzer support of mmap