Sean Perry d2d1f143e5
[z/OS] Add option to target older versions of LE on z/OS (#123399)
Add an option similar to the -qtarget option in XL to allow the user to
say they want to be able to run the generated program on an older
version of the LE environment. This option will do two things:
- set the `__TARGET_LIBS` macro so the system headers exclude newer
interfaces when targeting older environments
- set the arch level to match the minimum arch level for that older
version of LE. It doesn't happen right now since all of the supported LE
versions have a the same minimum ach level. So the option doesn't change
this yet.

The user can specify three different kinds of arguments:
1. -mzos-target=zosv*V*r*R* - where V & R are the version and release
2. -mzos-target=0x4vrrmmmm - v, r, m, p are the hex values for the
version, release, and modlevel
3. -mzos-target=current - uses the latest version of LE the system
headers have support for
2025-02-21 10:30:35 -05:00

19 lines
1.2 KiB
C

// REQUIRES: target={{s390x-ibm-zos}}
// In this case we expect __TARGET_LIB__ not to be defined because we don't
// include any files here, and in particular, any from the LE.
// RUN: %clang -mzos-target=current -dM -E %s | FileCheck --check-prefix=CURRENT %s
// CURRENT-NOT: #define __TARGET_LIB__
// RUN: %clang -mzos-target=zosv2r5 -dM -E %s | FileCheck --check-prefix=ZOSVR %s
// ZOSVR: #define __TARGET_LIB__ 0x42050000
// RUN: %clang -mzos-target=0x4204001f -dM -E %s | FileCheck --check-prefix=HEX %s
// HEX: #define __TARGET_LIB__ 0x4204001F
// RUN: not %clang -mzos-target=0x42010000 -dM -E %s 2>&1 | FileCheck --check-prefix=ERR-DISCONTINUED %s
// ERR-DISCONTINUED: z/OS target level "0x42010000" is discontinued. Unexpected behavior might occur if an out-of-support target level is specified. Use z/OS target level "zosv2r4", or later instead
// RUN: not %clang -mzos-target=Rubbish -dM -E %s 2>&1 | FileCheck --check-prefix=ERR-INVALID-ARG %s
// ERR-INVALID-ARG: "Rubbish" is not recognized as a valid z/OS target level. The z/OS target level must be "current", or of the form "zosvVrR", where "V" is the version and "R" is the release, or given as a "0x"-prefixed eight digit hexadecimal value