Skip to content

Support non-root building path #196

@txabman42

Description

@txabman42

Coming from #120 (comment)

Let's move demo/basic/main.go to demo/basic/cmd/main.go and execute go build -a cmd/ from basic folder. This would work without problem, however, when instrumenting it with otel (../../otel go build -a cmd/), it fails:

Error logs
# cmd/trace
net/http.OtelBeforeTrampoline_ServeHTTP802697909: relocation target github.com/open-telemetry/opentelemetry-go-compile-instrumentation/pkg/instrumentation/nethttp.BeforeServeHTTP not defined
Error:
[0] failed to run command "/usr/local/go/pkg/tool/darwin_arm64/link" with args: [-o $WORK/b661/exe/a.out -importcfg $WORK/b661/importcfg.link -X=cmd/internal/objabi.buildID=d3PxNBJKoXj5HhChQTjx/PqTyxeY2x3r8w-sZE2K0/JDzRK1jzYRrptT4B3Kcy/d3PxNBJKoXj5HhChQTjx -buildmode=pie -buildid=d3PxNBJKoXj5HhChQTjx/PqTyxeY2x3r8w-sZE2K0/JDzRK1jzYRrptT4B3Kcy/d3PxNBJKoXj5HhChQTjx -extld=clang $WORK/b661/_pkg_.a]: exit status 2

Same would happen for https://github.com/VictoriaMetrics/VictoriaMetrics --> otel go build -a ./app/vmctl

This is mainly because otel.runtime.go is not generated in the target folder, but in the root one. Linker wont be able to resolve linkname directives.

It could be also interesting to test the instrumentation of a library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions