Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using GCC_INSTRUMENT_PROGRAM_FLOW_ARCS and Firebase/Core #2235

Closed
fwigorcferreira opened this issue Jan 4, 2019 · 7 comments
Closed

Comments

@fwigorcferreira
Copy link

[READ] Step 1: Are you in the right place?

Yes

  • For issues or feature requests related to the code in this repository
    file a Github issue.

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.1
  • Firebase Component: Core
  • Component version: 5.0

[REQUIRED] Step 3: Describe the problem

Firebase/Core (since 5.0) blocks the execution of tests with GCC Instruments Program Flow Arcs enabled.

This can be seem by passing the instruction "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES" when building your app for testing, that output the error:

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The lack of this flag can have bad impacts on the generation of code coverage data, and limits the checks that can be done on code.

Steps to reproduce:

  • Create a project (any project) that has Firebase, and tests enabled.
  • Run the tests from terminal passing GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES as parameter.

Relevant Code:

Command:

set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild "-workspace" "PROJECT.xcworkspace" "-scheme" "PROJECT" "build" "test" "-destination" "platform=iOS Simulator,name=iPhone 6s Plus,OS=latest" "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES" "GCC_GENERATE_TEST_COVERAGE_FILES=YES"

Error:

Undefined symbols for architecture x86_64:
  "_llvm_gcov_init", referenced from:
      ___llvm_gcov_init in FirebaseCore(FIRApp.o)
      ___llvm_gcov_init.609 in FirebaseCore(FIRApp.o)
      ___llvm_gcov_init.674 in FirebaseCore(FIRApp.o)
      ___llvm_gcov_init.739 in FirebaseCore(FIRApp.o)
      ___llvm_gcov_init.804 in FirebaseCore(FIRApp.o)
      ___llvm_gcov_init.869 in FirebaseCore(FIRApp.o)
      ___llvm_gcov_init in FirebaseCore(FIRComponentType.o)
      ...
  "_llvm_gcda_end_file", referenced from:
      ___llvm_gcov_writeout in FirebaseCore(FIRApp.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRComponentType.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRDependency.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRAnalyticsConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRBundleUtil.o)
      ___llvm_gcov_writeout in FirebaseCore(FIROptions.o)
      ...
  "_llvm_gcda_emit_function", referenced from:
      ___llvm_gcov_writeout in FirebaseCore(FIRApp.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRComponentType.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRDependency.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRAnalyticsConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRBundleUtil.o)
      ___llvm_gcov_writeout in FirebaseCore(FIROptions.o)
      ...
  "_llvm_gcda_emit_arcs", referenced from:
      ___llvm_gcov_writeout in FirebaseCore(FIRApp.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRComponentType.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRDependency.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRAnalyticsConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRBundleUtil.o)
      ___llvm_gcov_writeout in FirebaseCore(FIROptions.o)
      ...
  "_llvm_gcda_start_file", referenced from:
      ___llvm_gcov_writeout in FirebaseCore(FIRApp.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRComponentType.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRDependency.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRAnalyticsConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRBundleUtil.o)
      ___llvm_gcov_writeout in FirebaseCore(FIROptions.o)
      ...
  "_llvm_gcda_summary_info", referenced from:
      ___llvm_gcov_writeout in FirebaseCore(FIRApp.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRComponentType.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRDependency.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRAnalyticsConfiguration.o)
      ___llvm_gcov_writeout in FirebaseCore(FIRBundleUtil.o)
      ___llvm_gcov_writeout in FirebaseCore(FIROptions.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@paulb777
Copy link
Member

paulb777 commented Jan 4, 2019

I'm not able to reproduce in a Firebase quickstart example.

The following command runs successfully:

set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild -workspace AnalyticsExample.xcworkspace/ -scheme AnalyticsExample build test -destination "platform=iOS Simulator,name=iPhone 6s Plus,OS=latest" "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES" "GCC_GENERATE_TEST_COVERAGE_FILES=YES"

Please provide more details about how to reproduce or send a reproducible example.

@fwigorcferreira
Copy link
Author

@paulb777 I'll close this issue, and re-open if/when I manage to create a simple project that showcase the bug.

@paulb777
Copy link
Member

paulb777 commented Jan 9, 2019

OK, thanks for update @fwigorcferreira. Perhaps, it's something to do with the Build Settings in your project?

@el-hoshino
Copy link

Having the same problem here. I also created a minimal project to reproduce this issue:
https://github.com/el-hoshino/FirebaseCocoaPodsTest

My Xcode version is 10.2, and I've tried CocoaPods with version 1.6.1 and 1.7.0.beta.3

@paulb777
Copy link
Member

@el-hoshino Thanks for the reproducible project!

I'm still not sure what triggers this issue in some projects but not others, but the workaround of adding -fprofile-arcs to Build Settings > Other Linker Flags gets it to build and test successfully. Thanks to https://stackoverflow.com/a/39579344/556617

@el-hoshino
Copy link

@paulb777 Thanks for the information! I'm trying this workaround and will report my result later!
One thing I found is that it seems projects created with Xcode 10.2 will have this problem, but older projects don't 🤔

@el-hoshino
Copy link

el-hoshino commented Apr 16, 2019

@paulb777 Confirmed! Passing -fprofile-arcs to OTHER_LDFLAGS works!

And I guess this command should work for you @fwigorcferreira :

set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild "-workspace" "PROJECT.xcworkspace" "-scheme" "PROJECT" "build" "test" "-destination" "platform=iOS Simulator,name=iPhone 6s Plus,OS=latest" "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES" "GCC_GENERATE_TEST_COVERAGE_FILES=YES" "OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -fprofile-arcs"

@firebase firebase locked and limited conversation to collaborators Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants