[cmake] avoid reference to xxhsum build directory #145
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#145
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello,
I'm making (unofficial) package for Archlinux (my distribution) and
makepkg(the distro package build tool) warns me thatxxhsumhas reference to build directory.I checked that with
and found only one occurrence. I tried to build the package with
--save-tempsflag for gcc and found theBUILD_DIRinxxhsum.o.sfile. I don't understand the format of that file but according to surroundings of the string it somehow might be related toXXXbenchHashfunction. Unfortunately, I couldn't figure out how that string comes to thexxhsum, I don't see any usage of special macros there.I would like to get rid of this string (see, for example, "reproducible builds") but now I'm lost and don't have any clue what to do further. Does anyone has idea how to get rid of this string in compiled binary or know how to debug the problem?
That's pretty strange.
There's nothing within
xxhsum.csource code susceptible to generate a reference toBUILD_DIR.I compiled it on a Linux mint vm, and made the same check as you :
It did not returned anything.
It might be an artifact of the build system.
I suppose that you use actual directory instead of BUILD_DIR, don't you? If you do then you may be right, this is artifact of my build tool. I'll try different system to check this out. As for my current system I can reproduce this manually:
Environment: bash 4.4.023, gcc 8.1.1 20180531, binutils 2.30, cmake 3.11.4, make 4.2.1, glibc 2.27.
Ah, I haven't tested
cmake, and it might be introducing this issue.I only tested the simpler
makebuild process :cmakeis 3rd-party maintained (hence the "unofficial" tag), I don't understand all its internals and side-effects, unfortunately, and only officially maintainMakefile.Hello,
for the record, I found the reason and workaround for the issue. In short: use the following
CMakeLists.txtfile and put it in top directory.Long story: the reference to the source directory is due to
__FILE__macro in all its forms. In this particular case it sneaks throughassertmacro. If one compiles the project within source directory there is no problem because in this case__FILE__is expanded (by compiler) to a relative path. But one of the most usedcmakefeature is compilation outside of source directory and in that case compiler expands the__FILE__macro to full path. However, it is possible to use paths relative to source directory but one has to redefine__FILE__macro. One may usecmakeas it is shown in the file above.Hello!
I beleave
assertmacro should be defined as(void)0ifNDEBUGis defined.NDEBUGis defined automatically by CMake if CMAKE_BUILD_TYPE is set to "Release" (for single-configuration generators like Unix Makefiles) or if building project with--config Releaseoption (for multiconfiguration generators like Xcode).For "RelWithDebInfo" build type one should define
NDEBUGby own in sources or in CMake lists.I've tested it just now.
Good luck!
The logic for
asserthas been updated, and is defined here :https://github.com/Cyan4973/xxHash/blob/dev/xxhash.c#L146
By default, all asserts in
xxhashare disabled.To enable them, it's required to set
DEBUGLEVELto a value>= 1.Even in this case,
assert()can still be disabled by settingNDEBUG.Whatever the value of
DEBUGLEVEL,NDEBUGsetting will not be modified,it remains exactly the same after including
xxhashcode(typically with
XXH_INLINE_ALL, which is the most impactful build type).I believe this issue has been fixed.
I tested a
cmake-producedxxhsumon a Linux system usingstrings, and it couldn't find any reference toBUILD_DIR.