-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Closed
Copy link
Labels
Description
'os.relativePath' got additional code:
when doslikeFileSystem:
if isAbsolute(path) and isAbsolute(base):
if not sameRoot(path, base):
return paththis changes also change it's behavior:
import os
let a = r"C:\Users\Jangko\.nimble\pkgs\eth-1.0.0\eth\common\utils.nim"
let b = r"F:\projects\bug"
debugEcho relativePath(a, b, '/')- Nim 1.0.2 produce: "../../../C:/Users/Jangko/.nimble/pkgs/eth-1.0.0/eth/common/utils.nim"
- Nim 1.1.1 produce: "C:\Users\Jangko.nimble\pkgs\eth-1.0.0\eth\common\utils.nim"
Nim compiler directly affected by this braking changes:
- in
pathutils.nim
proc relativeTo*(fullPath: AbsoluteFile, baseFilename: AbsoluteDir;
sep = DirSep): RelativeFile =
RelativeFile(relativePath(fullPath.string, baseFilename.string, sep))- in
packagehandling.nim
proc fakePackageName*(conf: ConfigRef; path: AbsoluteFile): string =
# foo-#head/../bar becomes @foo-@hhead@s..@sbar
result = "@m" & relativeTo(path, conf.projectPath, '/').string.multiReplace({"/": "@s", "#": "@h", "@": "@@", ":": "@c"})this bug actually detected before but with inconclusive ending.
- [regression] Importing more than one module with same name from different packages produce bad codegen #12420
- status-im/nimbus#424
how to reproduce:
- prepare a working windows machine + mingw gcc.
- compile nim compiler binary from
csources. - bootstrap a new compiler from that binary.
- do not use previous version compiler with 'good'
os.relativePathto boostrap a new compiler.
$> nimble install eth
$> nimble install nimcrypto
then compile this file with nim c --threads:on -d:metrics bug
# bug.nim
import eth/common/utils as autils, nimcrypto/utils
var x: array[100, byte]
burnMem(x)Current Output
C:\Users\Jangko\nimcache\bug_d\utils.nim.c.o:utils.nim.c:(.text+0x41e): multiple definition of `eth_utilsInit000'
C:\Users\Jangko\nimcache\bug_d\utils.nim.c.o:utils.nim.c:(.text+0x41e): first defined here
C:\Users\Jangko\nimcache\bug_d\@mbug.nim.c.o:@mbug.nim.c:(.text+0x225): undefined reference to `burnMem__haAOjkJjOuRy8ux9bV57dXw'
collect2.exe: error: ld returned 1 exit status
Possible Solution
os.relativePathneed to be fixed- or compiler internal avoid using the new 'broken' feature.
Additional Information
- It was working in version 1.0.2
- This issue is valid only on Windows.
$ nim -v
Nim Compiler Version 1.1.1 [Windows: amd64]
Compiled at 2019-11-25
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: 015bec625461826c3891110182b982c5dbb3208a
active boot switches: -d:release