Skip to content

Commit

Permalink
fix warnings in coreclr/jit/compiler.cpp for non-Windows targets
Browse files Browse the repository at this point in the history
This change was extracted from dotnet/runtimelab#2614,
which includes various fixes to enable building on non-Windows systems.  We're
in the process of upstreaming the parts of that PR which are not specific to
NativeAOT-LLVM, and this is the latest such change.

Note that I left a TODO comment in `DisplayNowayAssertMap` since I'm not sure
how to print a `LPCWSTR` using `fprintf` on non-Windows systems, but it's clear
that the existing code is not portable given the difference between `wchar_t` on
Windows (where it's 16 bits) and other systems (where it's usually 32 bits).

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
  • Loading branch information
dicej committed Jul 12, 2024
1 parent f9eda07 commit 760f3db
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,12 @@ void DisplayNowayAssertMap()
fout = _wfopen(strJitMeasureNowayAssertFile, W("a"));
if (fout == nullptr)
{
#if !defined(TARGET_WINDOWS)
// TODO: how do we print a `const char16_t*` portably?
#else
fprintf(jitstdout(), "Failed to open JitMeasureNowayAssertFile \"%ws\"\n",
strJitMeasureNowayAssertFile);
#endif
return;
}
}
Expand Down Expand Up @@ -1295,7 +1299,7 @@ void DisplayNowayAssertMap()

for (i = 0; i < count; i++)
{
fprintf(fout, "%u, %s, %u, \"%s\"\n", nacp[i].count, nacp[i].fl.m_file, nacp[i].fl.m_line,
fprintf(fout, "%u, %s, %u, \"%s\"\n", (unsigned int)nacp[i].count, nacp[i].fl.m_file, nacp[i].fl.m_line,
nacp[i].fl.m_condStr);
}

Expand Down Expand Up @@ -3390,7 +3394,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
if (verbose)
{
printf("STRESS_NULL_OBJECT_CHECK: compMaxUncheckedOffsetForNullObject=0x%X\n",
compMaxUncheckedOffsetForNullObject);
(unsigned int)compMaxUncheckedOffsetForNullObject);
}
}

Expand Down Expand Up @@ -9556,7 +9560,7 @@ void dumpConvertedVarSet(Compiler* comp, VARSET_VALARG_TP vars)
{
printf(" ");
}
printf("V%02u", varNum);
printf("V%02u", (unsigned int)varNum);
first = false;
}
}
Expand Down

0 comments on commit 760f3db

Please sign in to comment.