0

I am embeddingsrcs into a go_library to boostrap an embed.FS variable. It took some time to sort this out (see bazel go_embed_data "could not embed").

The new problem I have is I am receiving a SIGSEGV during runtime I'm seeing unexpected fault address 0x0

The bazel BUILD and go code is below

go_library(
    name = "my_lib",
    srcs = ["main.go"],
    embedsrcs = glob(["static/**/*"]),
    importpath = "github.com/myorg/myrepo",
    visibility = ["//visibility:private"],
    deps = ["//cmd"],
)

go_binary(
    name = "my_linux_amd64",
    cgo = True,
    embed = [":my_lib"],
    gc_goopts = [
        "-dynlink",
    ],
    goarch = "amd64",
    goos = "linux",
    linkmode = "pie",
    visibility = ["//visibility:public"],
)

package main

import (
    "embed"
)

//go:embed static/*
var staticFS embed.FS // fault address

Not sure how to resolve this.

a11hard
  • 1,904
  • 4
  • 19
  • 41

1 Answers1

0

Found this https://github.com/golang/go/issues/5337#issuecomment-66078444

TLDR; setting pure = "off" to set CGO_ENABLED=0 fixed the problem.

a11hard
  • 1,904
  • 4
  • 19
  • 41