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

Build failed on macOS #35

Open
akatsuki105 opened this issue Feb 20, 2021 · 5 comments
Open

Build failed on macOS #35

akatsuki105 opened this issue Feb 20, 2021 · 5 comments

Comments

@akatsuki105
Copy link

akatsuki105 commented Feb 20, 2021

At first I was going to submit an issue to agbcc, but agbcc was not accepting issues, so I'm submitting it here.

I tried to build bn6f.gba according to INSTALL.md, but build failed.

Environment

macOS Big Sur v11.1
Xcode v12.4(12D4e)
xcode-select version 2384

Command

❯ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

❯ git clone https://github.com/luckytyphlosion/agbcc -b new_layout_with_libs

❯ cd agbcc

❯ make         
Making ld
Making bfd
make[1]: Nothing to be done for `headers'.
make[1]: Nothing to be done for `objs'.
make[1]: Nothing to be done for `objs'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
make[2]: Nothing to be done for `all-am'.
Making libiberty
make[1]: Nothing to be done for `objs'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
cc -Wall -DELF_LIST_OPTIONS=TRUE -DELF_SHLIB_LIST_OPTIONS=TRUE -DELF_PLT_UNWIND_LIST_OPTIONS=FALSE -O2 -std=gnu11   -o ld-new ldgram.o ldlex-wrapper.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o  earmelf.o  ../bfd/libbfd.a ../libiberty/libiberty.a -lz 
ld: warning: ignoring file ../libiberty/libiberty.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../bfd/libbfd.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture x86_64:
  "__bfd_elf_map_sections_to_segments", referenced from:
      _gldarmelf_map_segments in earmelf.o
  "__bfd_elf_match_sections_by_type", referenced from:
      _gldarmelf_place_orphan in earmelf.o
  "__bfd_elf_tls_setup", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "__bfd_fix_excluded_sec_syms", referenced from:
      _finish_default in ldemul.o
  "__bfd_std_section", referenced from:
      _lang_init in ldlang.o
      _lang_add_section in ldlang.o
      _lang_size_sections_1 in ldlang.o
      _lang_do_assignments_1 in ldlang.o
      _section_already_linked in ldlang.o
      _lang_process in ldlang.o
      _print_statement in ldlang.o
      ...
  "__obstack_begin", referenced from:
      _lang_init in ldlang.o
      _lang_map in ldlang.o
  "__obstack_free", referenced from:
      _print_input_section in ldlang.o
  "__obstack_newchunk", referenced from:
      _stat_alloc in ldlang.o
      _new_afile in ldlang.o
      _lang_memory_region_lookup in ldlang.o
      _lang_memory_region_alias in ldlang.o
      _lang_add_section in ldlang.o
      _print_input_section in ldlang.o
      _sort_def_symbol in ldlang.o
      ...
  "__sch_istable", referenced from:
      _yylex in ldlex-wrapper.o
      _parse_args in lexsup.o
      _lang_process in ldlang.o
      _lang_leave_overlay_section in ldlang.o
      _lang_ld_feature in ldlang.o
      _ctor_cmp in ldctor.o
      _add_keepsyms_file in ldmain.o
      ...
  "__sch_tolower", referenced from:
      _name_compare in ldlang.o
      _ldfile_add_arch in ldfile.o
  "_bfd_arch_bits_per_address", referenced from:
      _lang_process in ldlang.o
  "_bfd_arch_get_compatible", referenced from:
      _lang_process in ldlang.o
      _ldfile_try_open_bfd in ldfile.o
  "_bfd_arch_mach_octets_per_byte", referenced from:
      _print_input_section in ldlang.o
      _lang_process in ldlang.o
      _print_statement in ldlang.o
  "_bfd_cache_close_all", referenced from:
      _ld_cleanup in ldmain.o
  "_bfd_canonicalize_reloc", referenced from:
      _warning_find_reloc in ldmain.o
      _check_reloc_refs in ldcref.o
  "_bfd_check_format", referenced from:
      _load_symbols in ldlang.o
      _lang_get_output_target in ldlang.o
      _walk_wild_file in ldlang.o
      _ldfile_try_open_bfd in ldfile.o
      _arm_elf_create_output_section_statements in earmelf.o
      _gldarmelf_open_dynamic_archive in earmelf.o
      _gldarmelf_try_needed in earmelf.o
      ...
  "_bfd_check_format_matches", referenced from:
      _load_symbols in ldlang.o
  "_bfd_close", referenced from:
      _load_symbols in ldlang.o
      _main in ldmain.o
      _ldfile_try_open_bfd in ldfile.o
      _gldarmelf_try_needed in earmelf.o
  "_bfd_create", referenced from:
      _arm_elf_create_output_section_statements in earmelf.o
  "_bfd_elf32_arm_add_glue_sections_to_bfd", referenced from:
      _arm_elf_create_output_section_statements in earmelf.o
  "_bfd_elf32_arm_allocate_interworking_sections", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_elf32_arm_get_bfd_for_interworking", referenced from:
      _arm_elf_create_output_section_statements in earmelf.o
  "_bfd_elf32_arm_init_maps", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_elf32_arm_keep_private_stub_output_sections", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_elf32_arm_process_before_allocation", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_elf32_arm_set_byteswap_code", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_elf32_arm_set_target_params", referenced from:
      _arm_elf_create_output_section_statements in earmelf.o
  "_bfd_elf32_arm_use_long_plt", referenced from:
      _gldarmelf_handle_option in earmelf.o
  "_bfd_elf_discard_info", referenced from:
      _gldarmelf_after_allocation in earmelf.o
  "_bfd_elf_get_bfd_needed_list", referenced from:
      _gldarmelf_try_needed in earmelf.o
  "_bfd_elf_get_dt_soname", referenced from:
      _gldarmelf_check_needed in earmelf.o
      _gldarmelf_vercheck in earmelf.o
      _gldarmelf_stat_needed in earmelf.o
  "_bfd_elf_get_dyn_lib_class", referenced from:
      _gldarmelf_after_open in earmelf.o
      _gldarmelf_check_needed in earmelf.o
      _gldarmelf_try_needed in earmelf.o
      _gldarmelf_stat_needed in earmelf.o
  "_bfd_elf_get_needed_list", referenced from:
      _gldarmelf_after_open in earmelf.o
  "_bfd_elf_parse_eh_frame_entries", referenced from:
      _gldarmelf_after_open in earmelf.o
  "_bfd_elf_record_link_assignment", referenced from:
      _gldarmelf_find_exp_assignment in earmelf.o
  "_bfd_elf_set_dt_needed_name", referenced from:
      _gldarmelf_open_dynamic_archive in earmelf.o
      _gldarmelf_try_needed in earmelf.o
  "_bfd_elf_set_dyn_lib_class", referenced from:
      _gldarmelf_load_symbols in earmelf.o
      _gldarmelf_try_needed in earmelf.o
  "_bfd_elf_size_dynamic_sections", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_elf_size_dynsym_hash_dynstr", referenced from:
      _arm_elf_before_allocation in earmelf.o
  "_bfd_emul_get_commonpagesize", referenced from:
      _after_parse_default in ldemul.o
  "_bfd_emul_get_maxpagesize", referenced from:
      _after_parse_default in ldemul.o
  "_bfd_emul_set_commonpagesize", referenced from:
      _set_output_arch_default in ldemul.o
  "_bfd_emul_set_maxpagesize", referenced from:
      _set_output_arch_default in ldemul.o
  "_bfd_errmsg", referenced from:
      _vfinfo in ldmisc.o
  "_bfd_generic_link_read_symbols", referenced from:
      _warning_callback in ldmain.o
      _vfinfo in ldmisc.o
      _check_nocrossref in ldcref.o
      _check_local_sym_xref in ldcref.o
  "_bfd_get_arch", referenced from:
      _arm_elf_create_output_section_statements in earmelf.o
  "_bfd_get_error", referenced from:
      _load_symbols in ldlang.o
      _ldlang_open_output in ldlang.o
      _ldwrite in ldwrite.o
      _vfinfo in ldmisc.o
      _ldfile_try_open_bfd in ldfile.o
  "_bfd_get_mach", referenced from:
      _arm_elf_create_output_section_statements in earmelf.o
  "_bfd_get_next_section_by_name", referenced from:
      _gldarmelf_place_orphan in earmelf.o
  "_bfd_get_reloc_code_name", referenced from:
      _ldctor_build_sets in ldctor.o
  "_bfd_get_reloc_size", referenced from:
      _lang_size_sections_1 in ldlang.o
      _lang_do_assignments_1 in ldlang.o
      _print_statement in ldlang.o
      _ldctor_build_sets in ldctor.o
      _build_link_order in ldwrite.o
  "_bfd_get_reloc_upper_bound", referenced from:
      _warning_find_reloc in ldmain.o
      _check_reloc_refs in ldcref.o
  "_bfd_get_section_by_name", referenced from:
      _init_os in ldlang.o
      _lang_process in ldlang.o
      _arm_elf_before_allocation in earmelf.o
  "_bfd_get_section_by_name_if", referenced from:
      _walk_wild_section_specs1_wild0 in ldlang.o
      _walk_wild_section_specs2_wild1 in ldlang.o
      _walk_wild_section_specs3_wild2 in ldlang.o
      _walk_wild_section_specs4_wild2 in ldlang.o
  "_bfd_get_section_contents", referenced from:
      _lang_process in ldlang.o
      _arm_elf_before_allocation in earmelf.o
  "_bfd_get_unique_section_name", referenced from:
      _ldwrite in ldwrite.o
  "_bfd_getb16", referenced from:
      _build_link_order in ldwrite.o
  "_bfd_getb32", referenced from:
      _build_link_order in ldwrite.o
  "_bfd_hash_allocate", referenced from:
      _lang_output_section_statement_lookup in ldlang.o
      _output_section_statement_newfunc in ldlang.o
      _definedness_newfunc in ldexp.o
      _add_cref in ldcref.o
      _cref_hash_newfunc in ldcref.o
      _handle_asneeded_cref in ldcref.o
  "_bfd_hash_lookup", referenced from:
      _lang_output_section_statement_lookup in ldlang.o
      _ldlang_override_segment_assignment in ldlang.o
      _lang_process in ldlang.o
      _exp_init_os in ldlang.o
      _add_ysym in ldmain.o
      _add_ignoresym in ldmain.o
      _add_wrap in ldmain.o
      ...
  "_bfd_hash_newfunc", referenced from:
      _lang_output_section_statement_lookup in ldlang.o
      _output_section_statement_newfunc in ldlang.o
      _add_ysym in ldmain.o
      _add_ignoresym in ldmain.o
      _add_wrap in ldmain.o
      _add_keepsyms_file in ldmain.o
      _undefined_symbol in ldmain.o
      ...
  "_bfd_hash_set_default_size", referenced from:
      _main in ldmain.o
  "_bfd_hash_table_free", referenced from:
      _lang_finish in ldlang.o
      _ldexp_finish in ldexp.o
      _handle_asneeded_cref in ldcref.o
  "_bfd_hash_table_init", referenced from:
      _add_keepsyms_file in ldmain.o
      _add_cref in ldcref.o
  "_bfd_hash_table_init_n", referenced from:
      _lang_init in ldlang.o
      _add_ysym in ldmain.o
      _add_ignoresym in ldmain.o
      _add_wrap in ldmain.o
      _undefined_symbol in ldmain.o
      _ldexp_init in ldexp.o
  "_bfd_hash_traverse", referenced from:
      _ldexp_finalize_syms in ldexp.o
      _output_cref in ldcref.o
      _check_nocrossrefs in ldcref.o
  "_bfd_init", referenced from:
      _main in ldmain.o
  "_bfd_iterate_over_targets", referenced from:
      _ldlang_open_output in ldlang.o
  "_bfd_link_add_undef", referenced from:
      _ldlang_add_undef in ldlang.o
      _lang_process in ldlang.o
      _exp_fold_tree_1 in ldexp.o
  "_bfd_link_check_relocs", referenced from:
      _lang_process in ldlang.o
  "_bfd_link_hash_lookup", referenced from:
      _ldlang_add_undef in ldlang.o
      _lang_process in ldlang.o
      _print_statement in ldlang.o
      _add_archive_element in ldmain.o
      _constructor_callback in ldmain.o
      _ldwrite in ldwrite.o
      _exp_fold_tree_1 in ldexp.o
      ...
  "_bfd_link_hash_traverse", referenced from:
      _lang_map in ldlang.o
      _print_input_section in ldlang.o
      _lang_process in ldlang.o
  "_bfd_make_section_anyway", referenced from:
      _ldwrite in ldwrite.o
  "_bfd_make_section_anyway_with_flags", referenced from:
      _init_os in ldlang.o
      _elf32_arm_add_stub_section in earmelf.o
  "_bfd_make_section_with_flags", referenced from:
      _gldarmelf_after_open in earmelf.o
  "_bfd_map_over_sections", referenced from:
      _ldlang_add_file in ldlang.o
      _warning_callback in ldmain.o
      _check_nocrossref in ldcref.o
      _check_local_sym_xref in ldcref.o
  "_bfd_new_link_order", referenced from:
      _build_link_order in ldwrite.o
  "_bfd_octets_per_byte", referenced from:
      _exp_fold_tree_1 in ldexp.o
  "_bfd_openr", referenced from:
      _ldfile_try_open_bfd in ldfile.o
      _arm_elf_create_output_section_statements in earmelf.o
      _gldarmelf_try_needed in earmelf.o
  "_bfd_openr_next_archived_file", referenced from:
      _load_symbols in ldlang.o
      _walk_wild_file in ldlang.o
      _ldfile_try_open_bfd in ldfile.o
  "_bfd_openw", referenced from:
      _ldlang_open_output in ldlang.o
      _gldarmelf_after_open in earmelf.o
  "_bfd_printable_name", referenced from:
      _lang_process in ldlang.o
  "_bfd_putl16", referenced from:
      _build_link_order in ldwrite.o
  "_bfd_putl32", referenced from:
      _build_link_order in ldwrite.o
  "_bfd_record_phdr", referenced from:
      _lang_process in ldlang.o
  "_bfd_reloc_type_lookup", referenced from:
      _ldctor_build_sets in ldctor.o
      _constructor_callback in ldmain.o
  "_bfd_scan_arch", referenced from:
      _ldfile_set_output_arch in ldfile.o
  "_bfd_scan_vma", referenced from:
      _yylex in ldlex-wrapper.o
      _parse_args in lexsup.o
      _set_segment_start in lexsup.o
      _lang_process in ldlang.o
      _after_parse_default in ldemul.o
      _gldarmelf_handle_option in earmelf.o
  "_bfd_section_already_linked_table_free", referenced from:
      _lang_process in ldlang.o
  "_bfd_section_already_linked_table_init", referenced from:
      _lang_process in ldlang.o
  "_bfd_set_assert_handler", referenced from:
      _main in ldmain.o
  "_bfd_set_default_target", referenced from:
      _main in ldmain.o
  "_bfd_set_error", referenced from:
      _yylex in ldlex-wrapper.o
      _main in ldmain.o
      _add_keepsyms_file in ldmain.o
      _ldwrite in ldwrite.o
      _ldfile_open_command_file_1 in ldfile.o
  "_bfd_set_error_handler", referenced from:
      _lang_process in ldlang.o
      _main in ldmain.o
  "_bfd_set_error_program_name", referenced from:
      _main in ldmain.o
  "_bfd_set_format", referenced from:
      _ldlang_open_output in ldlang.o
  "_bfd_set_gp_size", referenced from:
      _ldlang_add_file in ldlang.o
      _ldlang_open_output in ldlang.o
  "_bfd_set_start_address", referenced from:
      _lang_process in ldlang.o
  "_bfd_stat", referenced from:
      _gldarmelf_try_needed in earmelf.o
      _gldarmelf_stat_needed in earmelf.o
  "_bfd_target_list", referenced from:
      _help in lexsup.o
  "_bfd_wrapped_link_hash_lookup", referenced from:
      _exp_fold_tree_1 in ldexp.o
      _is_sym_value in ldexp.o
  "_concat", referenced from:
      _lang_add_input_file in ldlang.o
      _new_afile in ldlang.o
      _ldfile_add_library_path in ldfile.o
      _ldfile_open_file_search in ldfile.o
      _ldfile_open_command_file_1 in ldfile.o
  "_elf32_arm_build_stubs", referenced from:
      _gldarmelf_finish in earmelf.o
  "_elf32_arm_fix_exidx_coverage", referenced from:
      _gldarmelf_after_allocation in earmelf.o
  "_elf32_arm_next_input_section", referenced from:
      _build_section_lists in earmelf.o
  "_elf32_arm_setup_section_lists", referenced from:
      _gldarmelf_after_allocation in earmelf.o
  "_elf32_arm_size_stubs", referenced from:
      _gldarmelf_after_allocation in earmelf.o
  "_expandargv", referenced from:
      _main in ldmain.o
  "_filename_cmp", referenced from:
      _open_input_bfds in ldlang.o
      _walk_wild in ldlang.o
      _output_section_callback in ldlang.o
      _vfinfo in ldmisc.o
      _ldfile_open_file in ldfile.o
      _try_open in ldfile.o
      _gldarmelf_check_needed in earmelf.o
      ...
  "_filename_ncmp", referenced from:
      _load_symbols in ldlang.o
      _gldarmelf_vercheck in earmelf.o
      _gldarmelf_stat_needed in earmelf.o
  "_get_run_time", referenced from:
      _main in ldmain.o
  "_getpwd", referenced from:
      _gldarmelf_after_open in earmelf.o
  "_htab_create", referenced from:
      _lang_finalize_version_expr_head in ldlang.o
  "_htab_find", referenced from:
      _lang_vers_match in ldlang.o
      _lang_register_vers_node in ldlang.o
  "_htab_find_slot", referenced from:
      _lang_finalize_version_expr_head in ldlang.o
  "_htab_hash_string", referenced from:
      _version_expr_head_hash in ldlang.o
  "_lbasename", referenced from:
      _load_symbols in ldlang.o
      _gldarmelf_open_dynamic_archive in earmelf.o
      _gldarmelf_try_needed in earmelf.o
      _gldarmelf_vercheck in earmelf.o
      _gldarmelf_stat_needed in earmelf.o
  "_lrealpath", referenced from:
      _main in ldmain.o
      _try_open in ldfile.o
  "_make_relative_prefix", referenced from:
      _ldfile_open_command_file_1 in ldfile.o
  "_objalloc_free_block", referenced from:
      _handle_asneeded_cref in ldcref.o
  "_unlink_if_ordinary", referenced from:
      _ld_cleanup in ldmain.o
      _gldarmelf_after_open in earmelf.o
  "_xatexit", referenced from:
      _main in ldmain.o
  "_xexit", referenced from:
      _parse_args in lexsup.o
      _main in ldmain.o
      _ldwrite in ldwrite.o
      _vfinfo in ldmisc.o
      _ld_abort in ldmisc.o
  "_xmemdup", referenced from:
      _parse_args in lexsup.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [ld-new] Error 1
make[1]: *** [all] Error 2
make: *** [ld-all] Error 2
@luckytyphlosion
Copy link
Collaborator

Can you post the full log? Run

make clean
git clean -fX
make >build.log 2>&1

and copy the output of build.log here.

@akatsuki105
Copy link
Author

build.log

@luckytyphlosion
Copy link
Collaborator

This is super late, but try building with GNU Make (instructions here). macOS uses a different make which is apparently incompatible with GNU make required to build this.

@akatsuki105
Copy link
Author

Sorry for the late reply, got a successful build on my M1 Mac!

But I couldn't figure out exactly what was the reason for the success. Thank you in any case.

@akatsuki105
Copy link
Author

P.S. As for the gbagfx build, I had to add this code to the makefile.

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
CFLAGS += $(shell pkg-config --cflags libpng) $(shell pkg-config --libs libpng)
endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants