cmd/gogio: build for iOS/macOS without -fmodules and -fobjc-arc

The `gogio` tool adds the `-fmodules -fobjc-arc` flags to the Cgo
C flags. Unfortunately, that masks problems where Cgo packages
accidentally didn't have the flags in their #cgo directives such
as package log.

Move the flags so they're only explicitly mentioned when `gogio`
invokes the host compiler to build the `main.m` shim.

Fix package log to include the missing flags.

While we're here, silence OpenGL ES deprecation warnings on iOS, just
as we do for macOS. The warnings are normally not visible because
the gogio tool suppress output from the go tool.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-28 11:26:34 +01:00
parent a0692d74af
commit 4a26bdad5d
4 changed files with 9 additions and 4 deletions
+3 -1
View File
@@ -10,12 +10,14 @@ import (
/*
#cgo linux LDFLAGS: -lGLESv2 -ldl
#cgo darwin,!ios CFLAGS: -DGL_SILENCE_DEPRECATION
#cgo darwin,!ios LDFLAGS: -framework OpenGL
#cgo darwin,ios CFLAGS: -DGLES_SILENCE_DEPRECATION
#cgo darwin,ios LDFLAGS: -framework OpenGLES
#include <stdlib.h>
#ifdef __APPLE__
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE
#include <OpenGLES/ES3/gl.h>
+2
View File
@@ -5,6 +5,8 @@
package log
/*
#cgo CFLAGS: -fmodules -fobjc-arc -x objective-c
#include "log_ios.h"
*/
import "C"
+1 -1
View File
@@ -5,7 +5,7 @@
package window
/*
#cgo CFLAGS: -fmodules -fobjc-arc -x objective-c
#cgo CFLAGS: -DGLES_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
#include <CoreGraphics/CoreGraphics.h>
#include <UIKit/UIKit.h>
+3 -2
View File
@@ -184,6 +184,9 @@ int main(int argc, char * argv[]) {
lipo.Args = append(lipo.Args, exeSlice)
compile := exec.Command(clang, cflags...)
compile.Args = append(compile.Args,
"-fmodules",
"-fobjc-arc",
"-x", "objective-c",
"-F", tmpDir,
"-o", exeSlice,
mainm,
@@ -479,8 +482,6 @@ func iosCompilerFor(target, arch string) (string, []string, error) {
return "", nil, err
}
cflags := []string{
"-fmodules",
"-fobjc-arc",
"-fembed-bitcode",
"-Werror",
"-arch", allArchs[arch].iosArch,