Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dmd.mars: Add method to predefine FreeBSD_12 at compile-time. #11982

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ task:
timeout_in: 60m
environment:
OS_NAME: freebsd
CI_DFLAGS: -version=TARGET_FREEBSD12
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why dmd fails to compile with src/core/checkedint.d(691): Error: divide by zero if DFLAGS is exported in the environment.

install_bash_script: pkg install -y bash
<< : *COMMON_STEPS_TEMPLATE

Expand All @@ -84,5 +85,6 @@ task:
environment:
OS_NAME: freebsd
HOST_DC: dmd-2.079.0
CI_DFLAGS: -version=TARGET_FREEBSD11
install_bash_script: pkg install -y bash
<< : *COMMON_STEPS_TEMPLATE
4 changes: 3 additions & 1 deletion ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if [ -z ${FULL_BUILD+x} ] ; then echo "Variable 'FULL_BUILD' needs to be set.";
if [ -z ${MODEL+x} ] ; then echo "Variable 'MODEL' needs to be set."; exit 1; fi
# HOST_DC: dmd[-<version>]|ldc[-<version>]|gdmd-<version>
if [ -z ${HOST_DC+x} ] ; then echo "Variable 'HOST_DC' needs to be set."; exit 1; fi
# CI_DFLAGS: Optional flags to pass to the build
if [ -z ${CI_DFLAGS+x} ] ; then CI_DFLAGS=""; fi

CURL_USER_AGENT="DMD-CI $(curl --version | head -n 1)"
build_path=generated/$OS_NAME/release/$MODEL
Expand Down Expand Up @@ -50,7 +52,7 @@ clone() {
# build dmd, druntime, phobos
build() {
source ~/dlang/*/activate # activate host compiler, incl. setting `DMD`
make -j$N -C src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD ENABLE_RELEASE=1 ENABLE_WARNINGS=1 all
make -j$N -C src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" ENABLE_RELEASE=1 ENABLE_WARNINGS=1 all
make -j$N -C ../druntime -f posix.mak MODEL=$MODEL
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL
deactivate # deactivate host compiler
Expand Down
10 changes: 4 additions & 6 deletions src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,6 @@ private int tryMain(size_t argc, const(char)** argv, ref Param params)

setTarget(params);

// Predefined version identifiers
addDefaultVersionIdentifiers(params);

setDefaultLibrary();

// Initialization
Expand All @@ -388,6 +385,9 @@ private int tryMain(size_t argc, const(char)** argv, ref Param params)
import dmd.root.ctfloat : CTFloat;
CTFloat.initialize();

// Predefined version identifiers
addDefaultVersionIdentifiers(params);

if (params.verbose)
{
stdout.printPredefinedVersions();
Expand Down Expand Up @@ -1241,9 +1241,7 @@ void addDefaultVersionIdentifiers(const ref Param params)
{
VersionCondition.addPredefinedGlobalIdent("Posix");
VersionCondition.addPredefinedGlobalIdent("FreeBSD");
// FIXME: Need a way to statically and/or dynamically set the major FreeBSD version,
// to support FreeBSD 12.x and later releases both as a native and cross compiler.
VersionCondition.addPredefinedGlobalIdent("FreeBSD_11");
VersionCondition.addPredefinedGlobalIdent("FreeBSD_" ~ target.FreeBSDMajor);
VersionCondition.addPredefinedGlobalIdent("ELFv1");
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Clang");
}
Expand Down
19 changes: 19 additions & 0 deletions src/dmd/target.d
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,25 @@ extern (C++) struct Target
|| params.isDragonFlyBSD
|| params.isSolaris;
}

/**
* Returns:
* FreeBSD major version string being targeted.
*/
extern (D) @property string FreeBSDMajor() scope const nothrow @nogc
in { assert(params.isFreeBSD); }
do
{
// FIXME: Need better a way to statically set the major FreeBSD version?
version (TARGET_FREEBSD12) return "12";
else version (TARGET_FREEBSD11) return "11";
else version (TARGET_FREEBSD10) return "10";
else version (FreeBSD_12) return "12";
else version (FreeBSD_11) return "11";
else version (FreeBSD_10) return "10";
// FIXME: Need a way to dynamically set the major FreeBSD version?
else /* default supported */ return "11";
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down