CMake helper function 'find_link_library' is broken.
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- c, cmake
- Domain
- build-system
Research direction
Locate the CMake definition of find_link_library and inspect its fallback path after check_linker_flag fails. Correct the library lookup argument and ensure repeated calls do not reuse a prior result, then configure or build with a missing linker flag to verify the fallback finds the requested library and reports failure correctly.
Written by the indexing model from the issue text.
Description
The current implementation of the custom helper function 'find_link_library' is
function(find_link_library libname outlibname)
check_linker_flag(C "-l${libname}" mi_has_lib${libname})
if (mi_has_lib${libname})
message(VERBOSE "link library: -l${libname}")
set(${outlibname} ${libname} PARENT_SCOPE)
else()
find_library(MI_LIBPATH libname)
if (MI_LIBPATH)
message(VERBOSE "link library ${libname} at ${MI_LIBPATH}")
set(${outlibname} ${MI_LIBPATH} PARENT_SCOPE)
else()
message(VERBOSE "link library not found: ${libname}")
set(${outlibname} "" PARENT_SCOPE)
endif()
endif()
endfunction()
As it currently stands, it is 100% broken in the event the linker flag check fails, this is because it passes "libname" instead of "${libname}" to find_library AND will silently abort if MI_LIBPATH is set to a library path already (in a previous call).
To fix this, obviously "libname" -> "${libname}" is required, but one of two solutions can be deployed for the variable situation:
- Explicitly set "MI_LIBPATH" to the value "MI_LIBPATH-NOTFOUND" to force find_library to run, this can be a normal variable.
- Do what the linker flag check does and append "${libname}" to the test variable: "MI_LIBPATH" -> "MI_LIBPATH${libname}".
Markdown is hiding underscores in the suggested fixes for the MI_LIBPATH variable.
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/mimalloc
-
Mimalloc arena `mi_heap_malloc_aligned` has a hidden limit on max alignment of 64 KiB per allocation Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in microsoft/mimalloc
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·