Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions vlib/v/builder/cc.v
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
if os.uname().machine == 'Power Macintosh' {
user_darwin_ppc = true
}

// Mac OS 10.4 and older requires Macports legacy software to build programs
if user_darwin_version <= 8 {
ccoptions.args << "-I./thirdparty/legacy/include/LegacySupport/"
ccoptions.args << "./thirdparty/legacy/lib/libMacportsLegacySupport.a"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve legacy paths from compiler root

These new flags use ./thirdparty/legacy/..., which is resolved from the caller's current working directory rather than the V installation/repo root. setup_ccompiler_options runs for normal v builds from arbitrary project folders, so on Darwin <= 8 this will often point to missing files and fail with header/library not found errors. Please build these paths from @VEXEROOT/v.pref.vroot (and quote them) like other thirdparty references.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always a good idea. Just in case, somehow, the current directory gets changed, such that ./thirdparty is no longer correct.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move legacy archive out of compile args

The archive is added to ccoptions.args, which are emitted before source inputs in only_compile_args; that makes the static .a appear too early in the final command. On toolchains with order-sensitive static linking, the linker can scan libMacportsLegacySupport.a before the generated object and still report unresolved references (the exact issue this patch is trying to fix). This archive should be appended via linker flags so it is passed in link position.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 It works just fine on Mac OS 10.4.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, but wouldn't it be better to have the second line start with -L to ensure it is linked rather than included?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this and used this code:
ccoptions.args << "-L ./thirdparty/legacy/lib/libMacportsLegacySupport.a"
The result was the ld command failed to find the the symbols _backtrace and _backtrace_symbols_fd when trying to build a program.

}
}
ccoptions.debug_mode = v.pref.is_debug
ccoptions.guessed_compiler = v.pref.ccompiler
Expand Down
Loading