Skip to content

Commit

Permalink
Silence all warnings when building with GCC on Linux (#44350)
Browse files Browse the repository at this point in the history
* Silence all warnings when building with GCC on Linux

* Replace `#warning` with `#pragma message`

The former causes a compiler warning with Clang about it being a language
extension, which then causes an error if building with `-Werror`.

* Silence warning about unused variable when doing a non-debug build

* Initialise another variable which can be detected as uninitialised

* Fix more warnings introduced by recent changes
  • Loading branch information
giordano authored and Ian Atol committed Apr 4, 2022
1 parent 96e4731 commit 9576635
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static bool is_native_simd_type(jl_datatype_t *dt) {
#elif defined _CPU_PPC64_
typedef ABI_PPC64leLayout DefaultAbiState;
#else
# warning "ccall is defaulting to llvm ABI, since no platform ABI has been defined for this CPU/OS combination"
# pragma message("ccall is defaulting to llvm ABI, since no platform ABI has been defined for this CPU/OS combination")
typedef ABI_LLVMLayout DefaultAbiState;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3348,7 +3348,7 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
Value *ptindex = ctx.builder.CreateInBoundsGEP(getInt8Ty(ctx.builder.getContext()), emit_bitcast(ctx, maybe_decay_tracked(ctx, addr), getInt8PtrTy(ctx.builder.getContext())), ConstantInt::get(getSizeTy(ctx.builder.getContext()), fsz));
if (needlock)
emit_lockstate_value(ctx, strct, true);
BasicBlock *ModifyBB;
BasicBlock *ModifyBB = NULL;
if (ismodifyfield) {
ModifyBB = BasicBlock::Create(ctx.builder.getContext(), "modify_xchg", ctx.f);
ctx.builder.CreateBr(ModifyBB);
Expand Down
2 changes: 1 addition & 1 deletion src/crc32c.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static crc32c_func_t crc32c_dispatch(unsigned long hwcap)
# define crc32c_dispatch() crc32c_dispatch(getauxval(AT_HWCAP))
# define crc32c_dispatch_ifunc "crc32c_dispatch"
# else
# warning CRC32 feature detection not implemented for this OS. Falling back to software version.
# pragma message("CRC32 feature detection not implemented for this OS. Falling back to software version.")
# endif
#else
// If we don't have any accelerated version to define, just make the _sw version define
Expand Down
11 changes: 8 additions & 3 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags,
// number of extensions to try — if modname already ends with the
// standard extension, then we don't try adding additional extensions
int n_extensions = endswith_extension(modname) ? 1 : N_EXTENSIONS;
int ret;

/*
this branch returns handle of libjulia-internal
Expand Down Expand Up @@ -228,8 +229,12 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags,
path[0] = '\0';
if (relocated[len-1] == PATHSEPSTRING[0])
snprintf(path, PATHBUF, "%s%s%s", relocated, modname, ext);
else
snprintf(path, PATHBUF, "%s" PATHSEPSTRING "%s%s", relocated, modname, ext);
else {
ret = snprintf(path, PATHBUF, "%s" PATHSEPSTRING "%s%s", relocated, modname, ext);
if (ret < 0)
jl_errorf("path is longer than %d\n", PATHBUF);
}

#ifdef _OS_WINDOWS_
if (i == 0) { // LoadLibrary already tested the extensions, we just need to check the `stat` result
#endif
Expand Down Expand Up @@ -299,7 +304,7 @@ JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int t
*/
symbol_found = *value != NULL;
#ifndef _OS_WINDOWS_
const char *err;
const char *err = "";
if (!symbol_found) {
dlerror(); /* Reset error status. */
*value = dlsym(handle, symbol);
Expand Down
1 change: 1 addition & 0 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ static void serialize_htable_keys(jl_serializer_state *s, htable_t *ht, int nite
write_int32(s->s, nitems);
void **table = ht->table;
size_t i, n = 0, sz = ht->size;
(void)n;
for (i = 0; i < sz; i += 2) {
if (table[i+1] != HT_NOTFOUND) {
jl_serialize_value(s, (jl_value_t*)table[i]);
Expand Down
8 changes: 4 additions & 4 deletions src/gc-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,13 @@ void gc_time_summary(int sweep_full, uint64_t start, uint64_t end,
uint64_t pause)
{
if (sweep_full > 0)
jl_safe_printf("%ld Major collection: estimate freed = %ld
live = %ldm new interval = %ldm time = %ldms\n",
jl_safe_printf("%ld Major collection: estimate freed = %ld\n"
"live = %ldm new interval = %ldm time = %ldms\n",
end - start, freed, live/1024/1024,
interval/1024/1024, pause/1000000 );
else
jl_safe_printf("%ld Minor collection: estimate freed = %ld live = %ldm
new interval = %ldm time = %ldms\n",
jl_safe_printf("%ld Minor collection: estimate freed = %ld live = %ldm\n"
"new interval = %ldm time = %ldms\n",
end - start, freed, live/1024/1024,
interval/1024/1024, pause/1000000 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ StringRef JuliaOJIT::getFunctionAtAddress(uint64_t Addr, jl_code_instance_t *cod

#ifdef JL_USE_JITLINK
# if JL_LLVM_VERSION < 140000
# warning "JIT debugging (GDB integration) not available on LLVM < 14.0 (for JITLink)"
# pragma message("JIT debugging (GDB integration) not available on LLVM < 14.0 (for JITLink)")
void JuliaOJIT::enableJITDebuggingSupport() {}
# else
extern "C" orc::shared::CWrapperFunctionResult
Expand Down
2 changes: 1 addition & 1 deletion src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// for Mac/aarch64.
#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_)
# if JL_LLVM_VERSION < 130000
# warning "On aarch64-darwin, LLVM version >= 13 is required for JITLink; fallback suffers from occasional segfaults"
# pragma message("On aarch64-darwin, LLVM version >= 13 is required for JITLink; fallback suffers from occasional segfaults")
# endif
# define JL_USE_JITLINK
#endif
Expand Down

0 comments on commit 9576635

Please sign in to comment.