mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Use select to disable building static binaries if --cpu=darwin.
				
					
				
			This change allows kubectl to be built on MacOS machines using `bazel build //cmd/kubectl`. Mac OS X doesn't support static binaries because it does not have a stable syscall API. Userspace binaries are expected to dynamically link against libcrt instead. https://developer.apple.com/library/content/qa/qa1118/_index.html
This commit is contained in:
		@@ -7,12 +7,17 @@ load("//pkg/version:def.bzl", "version_x_defs")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
go_binary(
 | 
					go_binary(
 | 
				
			||||||
    name = "kubectl",
 | 
					    name = "kubectl",
 | 
				
			||||||
    gc_linkopts = [
 | 
					    gc_linkopts = select({
 | 
				
			||||||
 | 
					        # Mac OS X doesn't support static binaries:
 | 
				
			||||||
 | 
					        # https://developer.apple.com/library/content/qa/qa1118/_index.html
 | 
				
			||||||
 | 
					        "@io_bazel_rules_go//go/platform:darwin_amd64": [],
 | 
				
			||||||
 | 
					        "//conditions:default": [
 | 
				
			||||||
            "-linkmode",
 | 
					            "-linkmode",
 | 
				
			||||||
            "external",
 | 
					            "external",
 | 
				
			||||||
            "-extldflags",
 | 
					            "-extldflags",
 | 
				
			||||||
            "-static",
 | 
					            "-static",
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
    library = ":go_default_library",
 | 
					    library = ":go_default_library",
 | 
				
			||||||
    visibility = [
 | 
					    visibility = [
 | 
				
			||||||
        "//build/visible_to:COMMON_release",
 | 
					        "//build/visible_to:COMMON_release",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user