go icon indicating copy to clipboard operation
go copied to clipboard

sweet/harnesses: sweet fails when building esbuild a second time with the same configuration

Open yukatan1701 opened this issue 7 months ago • 1 comments

I used the following configuration for the esbuild benchmark:

# config.toml
[[config]]
  name = "myconfig"
  goroot = "/home/yukatan/golang"

Then run:

$ ./sweet run -run esbuild -shell -work-dir `pwd`/tmp config.toml

It worked fine. However, when I tried to run this again, I got the following error:

[sweet] Work directory: /home/yukatan/benchmarks/sweet/tmp
[sweet] Benchmarks: esbuild (10 runs)
[sweet] Setting up benchmark: esbuild
[shell] mkdir -p /home/yukatan/benchmarks/sweet/results/esbuild
[shell] mkdir -p /home/yukatan/benchmarks/sweet/tmp/esbuild/myconfig/bin
[shell] mkdir -p /home/yukatan/benchmarks/sweet/tmp/esbuild/src
[shell] mkdir -p /home/yukatan/benchmarks/sweet/tmp/esbuild/myconfig/tmp
[shell] ln -s /home/yukatan/benchmarks/sweet/tmp/esbuild/src /home/yukatan/benchmarks/sweet/tmp/esbuild/myconfig/bin/esbuild-src
[sweet] error: build esbuild for myconfig: symlink /home/yukatan/benchmarks/sweet/tmp/esbuild/src /home/yukatan/benchmarks/sweet/tmp/esbuild/myconfig/bin/esbuild-src: file exists

The symlink() function (harnesses/common.go) causes this error. It calls os.Symlink -> symlinkat but this syscall returns the error if the destination file exists. Unlike ln -s, symlink() doesn't handle this case.

yukatan1701 avatar Jun 14 '25 14:06 yukatan1701

Change https://go.dev/cl/680816 mentions this issue: sweet/harnesses: remove existing symlink before calling os.Symlink

gopherbot avatar Jun 14 '25 14:06 gopherbot

@mknyszek I will take a look later too.

JunyangShao avatar Jun 17 '25 17:06 JunyangShao