BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsls_buildtarget

Detailed Description

Provide build-target information in object files.

Outline

Purpose

Provide build-target information in object files.

Macros

See also
bsls_deprecate, bsls_assert, bsls_review

Description

The purpose of this component is to cause a link-time error when trying to link an executable with incompatible libraries. This component defines type names that indicate two build target parameters. These parameters determine whether the build was exception-enabled (which is the case unless overridden by defining the BDE_BUILD_TARGET_NO_EXC macro). The types defined by this component should not be used directly. This component also documents macros that can be used to disable checks that are performed elsewhere. Note that the deprecated macro BDE_BUILD_TARGET_MT is always defined for historical reasons where it was used to detect that a build supported multiple threads; there is no option to disable support for threading in BDE.

Compiler Version Check Macro

By design, programs using BDE fail to build if support for a C++ standard version is requested but the compiler's support for that standard is not sufficiently stable (possibly causing issues at runtime that are very difficult to debug). We provide the macro BDE_BUILD_SKIP_VERSION_CHECKS to disable these checks for the purpose of testing and experimenting with different compiler configurations. This macro should not be defined for integrated production builds such as dpkg, as doing so may result in unstable code being deployed to production.

Standard Version Inconsistency Check Macro

C++ object files built using a particular standard version must be linked with BDE libraries built using the same standard version, or else the program will be ill formed, no diagnostic required (IFNDR) and may exhibit issues at runtime that are very difficult to debug.

Deprecation Control Macros

In addition to the BDE_BUILD_TARGET_* macros that determine the link-time compatibility of different libraries built on BDE, this component documents a macro that determines whether deprecated interfaces are available to programs built on BDE:

BDE_OMIT_DEPRECATED: This macro, if defined, indicates that all code deprecated before BDE 3.2 will be either omitted from a build of the library (if the code has not been updated to use bsls_deprecate ), or identified to the compiler as deprecated (if the code has been updated to use bsls_deprecate ). New uses of this macro are not supported; use bsls_deprecate instead.

In addition to BDE_OMIT_DEPRECATED, there are two other macros that also determine whether deprecated interfaces are available to programs built on BDE:

BDE_OMIT_INTERNAL_DEPRECATED: This macro, if defined, indicates that all internal-only code deprecated before BDE 3.2 will be either omitted from a build of the library (if the code has not been updated to use bsls_deprecate ), or identified to the compiler as deprecated (if the code has been updated to use bsls_deprecate ). This category consists almost entirely of code that was already deprecated at the time of a component's initial release to open-source. New uses of this macro are not supported; use bsls_deprecate instead.

BDE_OPENSOURCE_PUBLICATION: This macro marks code that is not deprecated, but is nevertheless excluded from the open-source release of BDE. This category consists primarily of code that exists to support STLPort containers, which were not included in the open-source release, or that documents backward compatibility access to the package-prefix versions of non-deprecated symbols in BSL. BDE_OPENSOURCE_PUBLICATION exists for purposes of documentation only, and should not be defined for any build of the library. In particular, there is no guarantee that the library will build or will function correctly if BDE_OPENSOURCE_PUBLICATION is defined.

Together with BDE_OMIT_DEPRECATED, these macros divide the BDE codebase into four categories:

+-----------------------------------------+------------------------------+
| CATEGORY | LABEL |
+=========================================+==============================+
| universally distributed code | no label |
+-----------------------------------------+------------------------------+
| Bloomberg-only code | BDE_OPENSOURCE_PUBLICATION |
+-----------------------------------------+------------------------------+
| universally distributed code deprecated | BDE_OMIT_DEPRECATED |
| before BDE 3.2 | |
+-----------------------------------------+------------------------------+
| Bloomberg-only code deprecated before | BDE_OMIT_INTERNAL_DEPRECATED |
| BDE 3.2 | |
+-----------------------------------------+------------------------------+

By default, all code in BDE is both current and universally distributed. All code that is deprecated, excluded from our open-source distribution, or both, is surrounded with conditional compilation macros to allow test builds without that code, and/or to make it easy to prepare an open-source distribution from the full internal BDE codebase. The conditional compilation macros are:

Sanitizer Builds

There a flag set by the BDE build system to indicate when a build has a given sanitizer enabled:

BDE_BUILD_TARGET_ASAN: This macro, when defined, indicates that the current build mode includes address sanitizer.

BDE_BUILD_TARGET_MSAN: This macro, when defined, indicates that the current build mode includes memory sanitizer.

BDE_BUILD_TARGET_TSAN: This macro, when defined, indicates that the current build mode includes thread sanitizer.

BDE_BUILD_TARGET_UBSAN: This macro, when defined, indicates that the current build mode includes undefined behavior sanitizer.

Preprocessor conditionals on these macros are sometimes necessary when certain types of tests are incompatible with a given sanitizer, but their use should be rare, carefully considered, and appear only in test drivers.

Build Configuration Information

Several other macros that are defined, or not, to provide information about the build target that code might want to adjust for during translation.

BDE_BUILD_TARGET_32: This macro, when defined, indicates that the current build target will emit instructions for 32-bit architectures.

BDE_BUILD_TARGET_64: This macro, when defined, indicates that the current build target will emit instructions for 64-bit architectures.

BDE_BUILD_TARGET_OPT: This macro, when defined, indicates that the current build target will aggressively optimize code, potentially to the detriment of debug support. Undefined behavior is more likely to demonstrate adverse consequences that support better optimization. By default only OPT assertions will be evaluated — see bsls_assert and bsls_review for more details.

BDE_BUILD_TARGET_SAFE: This macro, when defined, indicates that the current build target will enable SAFE assertions — see bsls_assert and bsls_review for more details.

BDE_BUILD_TARGET_SAFE_2: This macro, when defined, indicates that the current build target will enable SAFE_2 assertions — see bsls_assert and bsls_review for more details.

BDE_DONT_ALLOW_TRANSITIVE_INCLUDES: This macro, when defined, indicates that the current build target will exclude #include directives that have been marked as present only to support higher level code that depended implicitly on that #include this is no longer necessary to compile the component itself. Note that attempts to define this macro on the command line passed to the compiler will be ignored, and the macro to force this definition, BDE_FORCE_DONT_ALLOW_TRANSITIVE_INCLUDES, should be defined instead. See bsls_ident for more details where the consistency rules regarding these macros are enforced.

Optimized Builds With Debug Information

Both macros BDE_BUILD_TARGET_OPT and BDE_BUILD_TARGET_DBG are defined when the build configuration includes optimization and debug flags (for example, opt_dbg UFID or RelWithDebInfo CMake build type).

Usage

There is no usage example for this component since it is not meant for direct client use.

Macro Definition Documentation

◆ BDE_BUILD_TARGET_EXC

#define BDE_BUILD_TARGET_EXC