Skip to content

Commit 3c08483

Browse files
authored
Silence all warnings when building with GCC on Linux (#44350)
* 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
1 parent 66c95f3 commit 3c08483

File tree

8 files changed

+18
-12
lines changed

8 files changed

+18
-12
lines changed

src/ccall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static bool is_native_simd_type(jl_datatype_t *dt) {
347347
#elif defined _CPU_PPC64_
348348
typedef ABI_PPC64leLayout DefaultAbiState;
349349
#else
350-
# warning "ccall is defaulting to llvm ABI, since no platform ABI has been defined for this CPU/OS combination"
350+
# pragma message("ccall is defaulting to llvm ABI, since no platform ABI has been defined for this CPU/OS combination")
351351
typedef ABI_LLVMLayout DefaultAbiState;
352352
#endif
353353

src/cgutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,7 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
33453345
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));
33463346
if (needlock)
33473347
emit_lockstate_value(ctx, strct, true);
3348-
BasicBlock *ModifyBB;
3348+
BasicBlock *ModifyBB = NULL;
33493349
if (ismodifyfield) {
33503350
ModifyBB = BasicBlock::Create(ctx.builder.getContext(), "modify_xchg", ctx.f);
33513351
ctx.builder.CreateBr(ModifyBB);

src/crc32c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static crc32c_func_t crc32c_dispatch(unsigned long hwcap)
346346
# define crc32c_dispatch() crc32c_dispatch(getauxval(AT_HWCAP))
347347
# define crc32c_dispatch_ifunc "crc32c_dispatch"
348348
# else
349-
# warning CRC32 feature detection not implemented for this OS. Falling back to software version.
349+
# pragma message("CRC32 feature detection not implemented for this OS. Falling back to software version.")
350350
# endif
351351
#else
352352
// If we don't have any accelerated version to define, just make the _sw version define

src/dlload.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags,
159159
// number of extensions to try — if modname already ends with the
160160
// standard extension, then we don't try adding additional extensions
161161
int n_extensions = endswith_extension(modname) ? 1 : N_EXTENSIONS;
162+
int ret;
162163

163164
/*
164165
this branch returns handle of libjulia-internal
@@ -228,8 +229,12 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags,
228229
path[0] = '\0';
229230
if (relocated[len-1] == PATHSEPSTRING[0])
230231
snprintf(path, PATHBUF, "%s%s%s", relocated, modname, ext);
231-
else
232-
snprintf(path, PATHBUF, "%s" PATHSEPSTRING "%s%s", relocated, modname, ext);
232+
else {
233+
ret = snprintf(path, PATHBUF, "%s" PATHSEPSTRING "%s%s", relocated, modname, ext);
234+
if (ret < 0)
235+
jl_errorf("path is longer than %d\n", PATHBUF);
236+
}
237+
233238
#ifdef _OS_WINDOWS_
234239
if (i == 0) { // LoadLibrary already tested the extensions, we just need to check the `stat` result
235240
#endif
@@ -299,7 +304,7 @@ JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int t
299304
*/
300305
symbol_found = *value != NULL;
301306
#ifndef _OS_WINDOWS_
302-
const char *err;
307+
const char *err = "";
303308
if (!symbol_found) {
304309
dlerror(); /* Reset error status. */
305310
*value = dlsym(handle, symbol);

src/dump.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ static void serialize_htable_keys(jl_serializer_state *s, htable_t *ht, int nite
10711071
write_int32(s->s, nitems);
10721072
void **table = ht->table;
10731073
size_t i, n = 0, sz = ht->size;
1074+
(void)n;
10741075
for (i = 0; i < sz; i += 2) {
10751076
if (table[i+1] != HT_NOTFOUND) {
10761077
jl_serialize_value(s, (jl_value_t*)table[i]);

src/gc-debug.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,13 +983,13 @@ void gc_time_summary(int sweep_full, uint64_t start, uint64_t end,
983983
uint64_t pause)
984984
{
985985
if (sweep_full > 0)
986-
jl_safe_printf("%ld Major collection: estimate freed = %ld
987-
live = %ldm new interval = %ldm time = %ldms\n",
986+
jl_safe_printf("%ld Major collection: estimate freed = %ld\n"
987+
"live = %ldm new interval = %ldm time = %ldms\n",
988988
end - start, freed, live/1024/1024,
989989
interval/1024/1024, pause/1000000 );
990990
else
991-
jl_safe_printf("%ld Minor collection: estimate freed = %ld live = %ldm
992-
new interval = %ldm time = %ldms\n",
991+
jl_safe_printf("%ld Minor collection: estimate freed = %ld live = %ldm\n"
992+
"new interval = %ldm time = %ldms\n",
993993
end - start, freed, live/1024/1024,
994994
interval/1024/1024, pause/1000000 );
995995
}

src/jitlayers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ StringRef JuliaOJIT::getFunctionAtAddress(uint64_t Addr, jl_code_instance_t *cod
11231123

11241124
#ifdef JL_USE_JITLINK
11251125
# if JL_LLVM_VERSION < 140000
1126-
# warning "JIT debugging (GDB integration) not available on LLVM < 14.0 (for JITLink)"
1126+
# pragma message("JIT debugging (GDB integration) not available on LLVM < 14.0 (for JITLink)")
11271127
void JuliaOJIT::enableJITDebuggingSupport() {}
11281128
# else
11291129
extern "C" orc::shared::CWrapperFunctionResult

src/jitlayers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// for Mac/aarch64.
3333
#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_)
3434
# if JL_LLVM_VERSION < 130000
35-
# warning "On aarch64-darwin, LLVM version >= 13 is required for JITLink; fallback suffers from occasional segfaults"
35+
# pragma message("On aarch64-darwin, LLVM version >= 13 is required for JITLink; fallback suffers from occasional segfaults")
3636
# endif
3737
# define JL_USE_JITLINK
3838
#endif

0 commit comments

Comments
 (0)