Bug 31294 - --gcc_flags not sent to ld when using incremental builds on target iPhone.
Summary: --gcc_flags not sent to ld when using incremental builds on target iPhone.
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: XI 8.10
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-06-22 14:20 UTC by Kostub Deshmukh
Modified: 2015-09-07 14:37 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Kostub Deshmukh 2015-06-22 14:20:31 UTC
When I try to build a Debug version on the iPhone and have incremental builds enabled, my build fails with a linker error. This seems to stem from the fact that I -gcc_flags set in additional options.

My other options field says:
-v -v -v -v -gcc_flags "-F${ProjectDir}/Frameworks"

When I build with incremental build on, the ld command line says:

    "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -dylib -arch arm64 -dylib_install_name @executable_path/libMathChatBinding.dll.dylib -iphoneos_version_min 7.0.0 -read_only_relocs suppress -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -ObjC -o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/MathChatBinding.dll.arm64.dylib /Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.1.64/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonosgen-2.0.dylib /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/libMathChatLib.a -framework AVFoundation -framework Accelerate -framework AudioToolbox -framework QuartzCore -framework CoreBluetooth -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework EventKit -framework Foundation -framework UIKit -framework GLKit -framework GameController -framework GameKit -framework ImageIO -framework JavaScriptCore -framework MapKit -framework MediaAccessibility -framework MobileCoreServices -framework Security -framework Social -framework SpriteKit -framework StoreKit -framework SystemConfiguration -framework AddressBook -framework Accounts -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework AssetsLibrary -framework CoreTelephony -framework EventKitUI -framework ExternalAccessory -framework CoreMotion -framework iAd -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Twitter -framework PassKit -framework MultipeerConnectivity -framework AddressBookUI -framework SafariServices -framework QuickLook -framework AdSupport -framework CFNetwork -framework Fabric -framework TwitterKit -framework ParseCrashReporting -framework ParseUI -framework Crashlytics -framework Parse -framework Appsee -framework Firebase -framework Bolts -framework FacebookSDK -framework ParseFacebookUtils -framework NewRelicAgent -weak_framework AVKit -weak_framework CloudKit -weak_framework SceneKit -weak_framework WebKit -weak_framework LocalAuthentication -weak_framework NetworkExtension -weak_framework HealthKit -weak_framework HomeKit -weak_framework Metal -weak_framework NotificationCenter -weak_framework Photos -weak_framework WatchKit -weak_framework CoreAudioKit -weak_framework PhotosUI -lz -licucore -lc++ -lstdc++.6 -lsqlite3 /var/folders/t1/c3bcv1gs57g5bkj58hwzzd1r0000gn/T/MathChatBinding-fd84cb.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.ios.a

When I build without the incremental build option, the command line looks like:

     "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch arm64 -iphoneos_version_min 7.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -u _mono_pmip -u _xamarin_init_nsthread -u _xamarin_start_wwan -u _xamarin_release_managed_ref -u _xamarin_create_managed_ref -u _xamarin_get_block_descriptor -u _xamarin_IntPtr_objc_msgSend_IntPtr -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr -u _xamarin_IntPtr_objc_msgSend_IntPtr_IntPtr_UInt32 -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr_IntPtr_UInt32 -u _xamarin_IntPtr_objc_msgSend_IntPtr_IntPtr_UInt64 -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr_IntPtr_UInt64 -u _xamarin_IntPtr_objc_msgSend_IntPtr_nint_nint_nint_UInt32 -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr_nint_nint_nint_UInt32 -u _xamarin_IntPtr_objc_msgSend_IntPtr_nint_nint_nint_UInt64 -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr_nint_nint_nint_UInt64 -u _xamarin_IntPtr_objc_msgSend_IntPtr_UInt32_nint_UInt32 -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr_UInt32_nint_UInt32 -u _xamarin_IntPtr_objc_msgSend_IntPtr_UInt64_nint_UInt64 -u _xamarin_IntPtr_objc_msgSendSuper_IntPtr_UInt64_nint_UInt64 -u _monotouch_GetFolderPath -u _monotouch_get_locale_country_code -u _monotouch_log -u _monotouch_timezone_get_names -u _monotouch_timezone_get_data -u _CreateZStream -u _CloseZStream -u _Flush -u _ReadZStream -u _WriteZStream -u _monotouch_start_wwan -u _mono_profiler_startup_log -ObjC -o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/64/Output/MathChat -lz -licucore -lc++ -lstdc++.6 -lsqlite3 -pie /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/MathChat.exe.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/Xamarin.iOS.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/System.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/System.Xml.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/System.Core.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/Mono.Dynamic.Interpreter.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/MathChatBinding.dll.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/registrar.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/main.arm64.o /Users/kostub/Projects/MathChat/MathChat/obj/iPhone/Debug/mtouch-cache/libMathChatLib.a -framework AVFoundation -framework Accelerate -framework AudioToolbox -framework QuartzCore -framework CoreBluetooth -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework EventKit -framework Foundation -framework UIKit -framework GLKit -framework GameController -framework GameKit -framework ImageIO -framework JavaScriptCore -framework MapKit -framework MediaAccessibility -framework MobileCoreServices -framework Security -framework Social -framework SpriteKit -framework StoreKit -framework SystemConfiguration -framework AddressBook -framework Accounts -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework AssetsLibrary -framework CoreTelephony -framework EventKitUI -framework ExternalAccessory -framework CoreMotion -framework iAd -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Twitter -framework PassKit -framework MultipeerConnectivity -framework AddressBookUI -framework SafariServices -framework QuickLook -framework AdSupport -framework CFNetwork -framework Fabric -framework TwitterKit -framework ParseCrashReporting -framework ParseUI -framework Crashlytics -framework Parse -framework Appsee -framework Firebase -framework Bolts -framework FacebookSDK -framework ParseFacebookUtils -framework NewRelicAgent -weak_framework AVKit -weak_framework CloudKit -weak_framework SceneKit -weak_framework WebKit -weak_framework LocalAuthentication -weak_framework NetworkExtension -weak_framework HealthKit -weak_framework HomeKit -weak_framework Metal -weak_framework NotificationCenter -weak_framework Photos -weak_framework WatchKit -weak_framework CoreAudioKit -weak_framework PhotosUI -lz -liconv /Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.1.64/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonosgen-2.0.a /Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.1.64/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-sgen-debug.a /Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.1.64/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libapp.a /Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.1.64/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmono-profiler-log.a -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.ios.a -F/Users/kostub/Projects/MathChat/MathChat/Frameworks

Note that in the second command line -F/Users/kostub/Projects/MathChat/MathChat/Frameworks exists while it doesn't in the first one and hence linking fails.

Note: This only happens when I am building for the iPhone. If I build for the iPhoneSimulator the build works fine even when incremental builds are turned on.
Comment 1 Naqeeb 2015-07-06 12:05:51 UTC
I have tried to reproduce this issue but not able to reproduce it. To reproduce this issue I have followed below steps.

1. Open XS on Mac.
2. Create "Single View App".
3. Go to project option under right click on project.
4. Checked option "Enable incremental build" 
5. Build/Run on iOS device in debug mode.

I am not getting linker error in both case when Checked option "Enable incremental build" and Unchecked option "Enable incremental build". Here is the screencast for the same.

Screencast: http://www.screencast.com/t/7np61gMc

Could you please provide Environment info, Ide log, Steps so that we can reproduce it at our end. 

If you are getting this issue with any specific solution then please provide
test sample. 

You can get Ide log via Help -> Open Log Directory and environment info via Xamarin Studio -> About Xamarin Studio.

Environment info:
=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 642986ef-b668-4108-b6e5-f58c62d668b6
Runtime:
 Mono 4.0.2 ((detached/c99aa0c)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 400020005

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: 8.10.2.37 (Enterprise Edition)
Hash: ef8c2f7
Branch: master
Build date: 2015-06-22 21:28:32-0400

=== Xamarin.Android ===

Version: 5.1.4.16 (Enterprise Edition)
Android SDK: /Users/360logica/Library/Developer/Xamarin/android-sdk-macosx
 Supported Android versions:
  2.3    (API level 10)
  4.0.3  (API level 15)
  4.4    (API level 19)
  4.4.87 (API level 20)
  5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.1.0.1195 (Enterprise Edition)

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.10.0
Darwin 360Logicas-MacBook-Pro.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Kostub Deshmukh 2015-07-06 13:22:05 UTC
Thanks for the screencast. For this to fail there need to be additional mtouch arguments specified in options the project that are required for linking.

Let me see if I can come up with a sample project which has this.
Comment 3 Kostub Deshmukh 2015-07-06 18:19:55 UTC
This is the Environment Information:

Xamarin Studio
Version 5.9.4 (build 5)
Installation UUID: dd24de67-65dd-482b-8c50-26fa62968dcd
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

Apple Developer Tools
Xcode 6.3.1 (7703)
Build 6D1002

Xamarin.iOS
Version: 8.10.3.2 (Trial Edition)
Hash: 8b265d6
Branch: master
Build date: 2015-06-30 15:19:13-0400

Xamarin.Android
Version: 5.1.4.16 (Trial Edition)
Android SDK: /Users/kostub/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Xamarin Android Player
Not Installed

Xamarin.Mac
Not Installed

Build Information
Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

Operating System
Mac OS X 10.10.3
Darwin gauss.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 5 Kostub Deshmukh 2015-07-15 14:34:38 UTC
Added the requested information.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2015-09-07 14:36:53 UTC
This is what happens:

Normally (with incremental builds), we compile each dll into a static library, and then link all those together (adding -gcc_flags) to create the executable.

When enabling incremental builds, we build each dll to a native dylib, but we don't add -gcc_flags when linking the dylib (because it's quite normal for -gcc_flags to specify static libraries, and adding -gcc_flags when building each dylib, would mean that each static library specified by -gcc_flags would end up in every dylib, one for each assembly).

But for binding assemblies, we add the linker flags specified in the LinkWith attribute for that binding assembly. This is how libTestBinding.dylib ends up trying to link with your custom frameworks, but it doesn't work since only half the required information to link libTestBinding.dylib is in the LinkWith attribute, the rest is in -gcc_flags.

The good news is that we're adding support for user frameworks in Xamarin.iOS 9.0, and you'll be able to add the user frameworks to link with in the project (and we'll do the right thing and link with those frameworks when building each native dylib with incremental builds).