New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the error of making symlink in setupCompilerEnvironmentPhase. #84985
Changes from 3 commits
ec3f150
6c7abfe
ee9da4f
ca22a65
e78bfb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,11 +383,29 @@ stdenv.mkDerivation ({ | |
mv tmp "$d" | ||
done | ||
|
||
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do | ||
for lib in "$d/"*.{dylib,so}; do | ||
ln -s "$lib" "$dynamicLinksDir" | ||
makeDynamicLinks () { | ||
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do | ||
for lib in "$d/"*.{dylib,so} ; do | ||
# When '*.{dylib,so}' does not match anything, '*.{dylib,so}' becomes '*.dylink or *.so' including '*' | ||
# [ -f "$lib" ] checks if the matched path is available. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
if [ -f "$lib" ] ; then | ||
local linkPath="$dynamicLinksDir/$(basename "$lib")" | ||
if [ -e "$linkPath" ]; then | ||
# link already exists! but maybe that's OK | ||
if [ ! -L "$linkPath" ] || [ "$(readlink "$linkPath")" != "$lib" ]; then | ||
echo >&2 "error: failed to create symbolic link $linkPath: file exists" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest explicitly not making this error look like a standard file exists error, this only seems misleading. How about "Not attempting to link from <x> to <y> because <reason>" instead |
||
exit 1 | ||
fi | ||
else | ||
ln -s "$lib" "$linkPath" | ||
fi | ||
fi | ||
done | ||
done | ||
done | ||
} | ||
|
||
makeDynamicLinks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't need to be a function, you can just inline it here |
||
|
||
# Edit the local package DB to reference the links directory. | ||
for f in "$packageConfDir/"*.conf; do | ||
sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," "$f" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@junjihashimoto Is there a reason for putting this in a function?
Also, could you add some more comments to this code? It is not clear what it is doing or why it is needed. (I know it didn't have any comments to start out with, but it would be nice to get some comments now, hopefully since you have a good idea of what it is doing.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Sorry for bothering you.
https://github.com/hasktorch/hasktorch/runs/578941364?check_suite_focus=true
This version using makeDynamicLinks fails.
https://github.com/hasktorch/hasktorch/runs/541868184
The test using
ln -sf
passes.I seem to misunderstand the problem.