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

on OSX, the -fstatic flag should be ignored (or not static link crt0 ) #6771

Closed
cartazio opened this issue Oct 24, 2020 · 9 comments
Closed

Comments

@cartazio
Copy link

while having a go at building pandoc with -fstatic -fembed_data_files
i realized that the former isn't setup correctly / may never work on osx?

Linking dist/build/pandoc/pandoc ...
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`clang' failed in phase `Linker'. (Exit code: 1)
cabal: Failed to build exe:pandoc from pandoc-2.11.0.4. See the build log
above for details.

it seems like theres a bug / design flaw in -fstatic is done

edit: looking at the .cabal file

  if flag(static)
    ld-options:     -static

unconditional -static is definitely wrong

@jgm
Copy link
Owner

jgm commented Oct 26, 2020

Yes, I don't think fully static linking is possible on macOS.

But making the effect of static flag conditional seems wrong also; we don't want people thinking that they succeeded in doing a static build when the flag is silently ignored.

@cartazio
Copy link
Author

cartazio commented Oct 26, 2020 via email

@jgm
Copy link
Owner

jgm commented Oct 26, 2020

What about setting Buildable to False if static is selected on macOS?
That would be a CPP-less solution, though perhaps less informative.

@cartazio
Copy link
Author

anything is definitely better than what it currently does, honestly whatever you feel happiest with, i do think some sort of feedback is better than flags silently being accepted which have never worked before

@jgm jgm closed this as completed in 46bbdad Nov 18, 2020
@jgm
Copy link
Owner

jgm commented Nov 18, 2020

I've used the buildable: False approach.
But now that I look at it, is there a point to having the 'static' flag any more? All it does is set

    ld-options:     -static

But if I'm not mistaken, that can be done now by using the option --enable-executable-static with cabal (or executable-static: true in project file). If not, it's always possible to set the linker options on the command line. (With stack, I think that's the only way.) Currently to make our static build we us

cabal v2-configure --enable-tests -f-export-dynamic -fstatic -fembed_data_files --enable-executable-static --ghc-options '-optc-Os -optl=-pthread -split-sections' pandoc

Not sure that's all necessary; I think -fstatic is redundant with --enable-executable-static, and even if it wasn't, we could just add another -optl=-static to the list.

Will reopen in case anyone wants to comment.

@jgm jgm reopened this Nov 18, 2020
@cartazio
Copy link
Author

cartazio commented Nov 18, 2020 via email

@jgm
Copy link
Owner

jgm commented Nov 19, 2020

Really? The docs for --enable-executable-static say:
"Build fully static executables. This links all dependent libraries into executables statically, including libc. "

@cartazio
Copy link
Author

cartazio commented Nov 19, 2020 via email

@jgm
Copy link
Owner

jgm commented Nov 19, 2020

I think I'll just remove the static flag.
It's more likely to lead people astray than to help.

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