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

Issue when building fish-shell from latest source for Cygwin #2952

Closed
v7rzlhb3xg opened this issue Apr 17, 2016 · 11 comments
Closed

Issue when building fish-shell from latest source for Cygwin #2952

v7rzlhb3xg opened this issue Apr 17, 2016 · 11 comments
Assignees
Milestone

Comments

@v7rzlhb3xg
Copy link

Issue:

autoconf and ./configure run fine, however when I run make I get the following error:

{ fish-shell } master » make
g++ -g -O2 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -fno-exceptions -Wall -Wno-sign-compare  -Ipcre2-10.20/src -iquote. -iquote./src/ -DLOCALEDIR=\"/usr/local/share/locale\" -DPREFIX=L\"/usr/local\" -DDATADIR=L\"/usr/local/share\" -DSYSCONFDIR=L\"/usr/local/etc\" -DBINDIR=L\"/usr/local/bin\" -DDOCDIR=L\"/usr/local/share/doc/fish\"  -DFISH_BUILD_VERSION=\"2.2.0-775-gf034d8b\" -c src/history.cpp -o obj/history.o
src/history.cpp: In member function ‘bool history_t::save_internal_via_rewrite()’:
src/history.cpp:1433:52: error: ‘mkostemp’ was not declared in this scope
             out_fd = mkostemp(narrow_str, O_CLOEXEC);
                                                    ^
Makefile:805: recipe for target 'obj/history.o' failed
make: *** [obj/history.o] Error 1

Reproduction Steps:

  1. git clone https://github.com/fish-shell/fish-shell.git
  2. cd fish-shell
  3. autoconf
  4. ./configure
  5. make

Expected behavior:

Fish should compile correctly

Observed behavior:

Fish does not compile and instead returns an error.

Additional information:

Windows 10 running Babun 1.2.0/Cygwin


Fish version: current source

Operating system: Windows 10, attempting to build from Git

Terminal or terminal emulator: MinTTy

@krader1961
Copy link
Contributor

Configure determined you have mkostemp() but when fish was actually being compiled the necessary declaration in a header file wasn't seen. You're not trying to mix the new Windows 10 linux subsystem with cygwin are you? Assuming you're not we'll need to see the config.log file.

@v7rzlhb3xg
Copy link
Author

Nope, I'm on Win10 build 10586 which doesn't have the Linux subsystem implemented yet.

config.log: http://pastebin.com/XyPkeXXh

@krader1961
Copy link
Contributor

Autoconf, which creates the configure script, is simply testing that a trivial program can be compiled and linked into an executable. Which is to say it is doing nothing more than verifying a public text symbol (i.e., function name) exists in a library that is linked into C/C++ binaries. On OS X that test actually fails which causes the configure script to show the source of that trivial program in the configure.log file.

The actual fish compile failure is because a header file included by the fish sources (directly or indirectly) doesn't declare the mkostemp function (i.e., provide a signature for it). The mkostemp function is typically declared in stdlib.h.

Is the Cygwin build environment you're using especially old or new?

I'm guessing this might be a namespace issue. Why? Because the trivial program used by autconf/configure doesn't use any namespaces. Whereas the src/history.cpp file does. What happens if you replace the mkostemp() call in src/history.cpp with std::mkostemp()? That transformation shouldn't be needed AFAIK but I'm curious it if fixes your build failure. If it does not fix your problem where in your system header files is mkostemp declared?

@v7rzlhb3xg
Copy link
Author

v7rzlhb3xg commented Apr 18, 2016

My Cygwin build environment is the current release version. Unfortunately, replacing mkostemp() with std::mkostemp() didn't solve the build failure.

I'm not sure how to find where in my header files it's declared, howeber grep -R mkostemp in usr/include/ returned:

$ grep -R mkostemp
cygwin/version.h:      229: Add mkostemp, mkostemps.
stdlib.h:int    _EXFUN(mkostemp,(char *, int));
stdlib.h:int    _EXFUN(mkostemps,(char *, int, int));
stdlib.h:int    _EXFUN(_mkostemp_r, (struct _reent *, char *, int));
stdlib.h:int    _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int));

@krader1961
Copy link
Contributor

krader1961 commented Apr 19, 2016

Okay, the std:: namespace idea was a SWAG so I'm not surprise it didn't make a difference. Other than the slightly unusual way in which the mkostemp function is declared it's in the expected header file which should be included when fish modules are compiled. It seems unlikely that the _EXFUN macro isn't producing a valid external function declaration but I don't know what else to think. Since I don't have a MS Windows system setup to build fish I'm going to disengage and hope someone who does have such an environment can provide better help with this than I can.

@v7rzlhb3xg
Copy link
Author

Thanks for your assistance so far, I appreciate it.

@zanchey
Copy link
Member

zanchey commented Apr 21, 2016

I think this is because of a change in Cygwin. I could build just fine on my Windows Server 2008 R2 system, and then I updated to the latest Cygwin packages - now I can reproduce this problem.

The obvious suspect is libstdc++6 which I upgraded from 4.9.3-1 to 5.3.0-5.

@zanchey
Copy link
Member

zanchey commented Apr 21, 2016

I take it back - this is a change in the cygwin-devel package which went from 2.4.1 to 2.5.0. In particular, mkostemp now requires _GNU_SOURCE to be defined before it is available... which makes me curious as to why the configure check passes.

@ridiculousfish
Copy link
Member

Based on the chat, probably the header is something like:

#ifdef _GNU_SOURCE
    int mkostemp(char*, int);
#endif

however the AC_CHECK_FUNCS call looks to see if the function can be linked, not if it has a declaration. I think switching this to AC_CHECK_DECLS might fix it.

zanchey added a commit to zanchey/fish-shell that referenced this issue Apr 21, 2016
zanchey added a commit to zanchey/fish-shell that referenced this issue Apr 21, 2016
@zanchey zanchey added this to the 2.3.0 milestone Apr 25, 2016
@andrew-schulman
Copy link
Contributor

Confirmed, this fixes the build failure. Thanks!

@zanchey
Copy link
Member

zanchey commented May 6, 2016

This was fixed in 0e7ab7a.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
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

5 participants