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

nmake fails to build on FreeBSD 11.0 and 11.1 #26

Closed
ghost opened this issue Dec 8, 2016 · 15 comments
Closed

nmake fails to build on FreeBSD 11.0 and 11.1 #26

ghost opened this issue Dec 8, 2016 · 15 comments

Comments

@ghost
Copy link

ghost commented Dec 8, 2016

This is probably the wrong place to get help. I'm trying to get a recent version of ksh going so I can install CDE. When I run ./bin/package make, it gives me this error and fails compiling ast.

`mamake [cmd/nmake]: *** exit code 1 making expand.o

  • nmake --base --compile '--file=/home/wfisher/ast/src/cmd/nmake/Makerules.mk'
    /bin/sh: nmake: not found
    mamake [cmd/nmake]: *** exit code 127 making Makerules.mo
    mamake: *** exit code 1 making cmd/nmake
    package: make: errors making /home/wfisher/ast/arch/freebsd11.amd64/bin/nmake`

I don't know if I'm compiling things wrong or missing a dependency but the Googles hasn't turned up any help.

Thanks!!

@saper
Copy link
Contributor

saper commented Jul 1, 2017

(corrected)

It happens to me on 11 (11.1-PRERELEASE) but only when running bin/package flat make from the git repository; when building an updated port version I am trying to fix right now it does not happen - it fails on 11.x due to #48 instead.

@saper
Copy link
Contributor

saper commented Jul 1, 2017

Seems to be caused by this:

+ cc -D_BLD_DLL -fPIC -D_BLD_ast -O -I. -I/home/saper/sw/ast/src/lib/libast -Icomp -I/home/saper/sw/ast/src/lib/libast/comp -Ivmalloc -I/home/saper/
sw/ast/src/lib/libast/vmalloc -Iinclude -I/home/saper/sw/ast/src/lib/libast/include -Istd -I/home/saper/sw/ast/src/lib/libast/std -D_PACKAGE_ast -c
/home/saper/sw/ast/src/lib/libast/vmalloc/vmdcshare.c
/home/saper/sw/ast/src/lib/libast/vmalloc/vmdcshare.c:187:10: error: use of undeclared identifier 'ALIGN'
        size += MMHEAD(mmdc->name) + ALIGN;
+ cc -D_BLD_DLL -fPIC -D_BLD_ast -O -I. -I/home/saper/sw/ast/src/lib/libast -Icomp -I/home/saper/sw/ast/src/lib/libast/comp -Ivmalloc -I/home/saper/
sw/ast/src/lib/libast/vmalloc -Iinclude -I/home/saper/sw/ast/src/lib/libast/include -Istd -I/home/saper/sw/ast/src/lib/libast/std -D_PACKAGE_ast -c
/home/saper/sw/ast/src/lib/libast/vmalloc/vmdcshare.c
/home/saper/sw/ast/src/lib/libast/vmalloc/vmdcshare.c:187:10: error: use of undeclared identifier 'ALIGN'
        size += MMHEAD(mmdc->name) + ALIGN;
                ^
/home/saper/sw/ast/src/lib/libast/vmalloc/vmdcshare.c:70:57: note: expanded from macro 'MMHEAD'
#define MMHEAD(name)    ROUND(sizeof(Mmvm_t)+strlen(name), ALIGN)
                                                           ^
```

@siteshwar
Copy link
Contributor

I am getting this error too under FreeBSD 11.0-RELEASE-p1 :

/home/situ/ast/src/lib/libast/comp/setlocale.c:2192:88: error: use of undeclared identifier 'EILSEQ'
        if (m == (size_t)(-2) && (q->mb_errno = E2BIG) || m == (size_t)(-1) && (q->mb_errno = EILSEQ))

@saper
Copy link
Contributor

saper commented Jul 2, 2017

Interesting, haven't seen that one at all. EILSEQ is there defined in <errno.h>, it should be there and it is included pretty late in the setlocale.c file

@siteshwar
Copy link
Contributor

siteshwar commented Jul 4, 2017

It was fixed by installing libiconv package.

@dannyweldon
Copy link

dannyweldon commented Jul 4, 2017 via email

@siteshwar
Copy link
Contributor

Yes, the error at #26 (comment) was fixed by installing libiconv package on FreeBSD.

@saper
Copy link
Contributor

saper commented Jul 5, 2017

lbiconv is not required, I've had it built successfully without it. Can you check your /usr/include/errno.h and see if the missing symbol is there? How did you install FreeBSD?

@siteshwar
Copy link
Contributor

I installed it from this iso.

@dannyweldon
Copy link

dannyweldon commented Jul 5, 2017

@siteshwar What dependencies does the libiconv package have?

I think these command might work but I haven't tested them?

pkg info -d libiconv

Then check what files are in each dependant package:

pkg info -l PACKAGE

@siteshwar
Copy link
Contributor

The symbol is there is /usr/include/errno.h, but it looks like it is not defined during compilation.

@saper
Copy link
Contributor

saper commented Jul 9, 2017

@siteshwar reproduced your error: before this you get this problem:

+ cc -D_BLD_DLL -fPIC -D_BLD_ast -O -I. -I/home/saper/src/ast-beta/src/lib/libast -Icomp -I/home/saper/src/a
st-beta/src/lib/libast/comp -Iinclude -I/home/saper/src/ast-beta/src/lib/libast/include -Istd -I/home/saper/
src/ast-beta/src/lib/libast/std -D_PACKAGE_ast -c /home/saper/src/ast-beta/src/lib/libast/misc/state.c
In file included from /home/saper/src/ast-beta/src/lib/libast/misc/state.c:26:
In file included from /home/saper/src/ast-beta/src/lib/libast/include/ast.h:34:
In file included from /home/saper/src/ast-beta/src/lib/libast/include/ast_std.h:101:
In file included from ./ast_wchar.h:99:
/usr/include/../include/wchar.h:107:24: error: typedef redefinition with different types ('struct __sFILE' vs 'struct _sfio_s')
typedef struct __sFILE FILE;
                       ^
./ast_stdio.h:82:15: note: expanded from macro 'FILE'
#define FILE            _sfio_FILE
                        ^
./ast_stdio.h:80:24: note: previous definition is here
typedef struct _sfio_s _sfio_FILE;
                       ^
1 error generated.

This is fixed by a patch FreeBSD port has been applying for some time.

Another fix needed is to rename SF_* constants:

sed -i.orig -e 's|SF_FLAGS|SFIO_FLAGS|g' src/lib/libast/include/sfio*.h src/lib/libast/sfio/*.c

I don't know how to fix it in the ksh code repository without breaking SFIO API.

Other that that, you will need patches from #19 to make it build.

... and also, you will need a fix for #48 which is #50 :)

@saper
Copy link
Contributor

saper commented Jul 9, 2017

I have pulled all the patches currently needed to build beta on FreeBSD 11 into one branch https://github.com/saper/ast/tree/beta-20170709

@krader1961 krader1961 changed the title nmake missing on FreeBSD 11.0 nmake fails to build on FreeBSD 11.0 Oct 29, 2017
@krader1961 krader1961 changed the title nmake fails to build on FreeBSD 11.0 nmake fails to build on FreeBSD 11.0 and 11.1 Oct 29, 2017
@krader1961
Copy link
Contributor

krader1961 commented Oct 29, 2017

I created a new FreeBSD 11.1 virtual machine containing the bare minimum of packages needed to compile this project. I'm getting the EILSEQ not defined build failure on FreeBSD 11.1 using gcc and clang:

/usr/home/krader/projects/3rd-party/ast/src/lib/libast/comp/setlocale.c:2192:88: error: use of undeclared identifier 'EILSEQ'
        if (m == (size_t)(-2) && (q->mb_errno = E2BIG) || m == (size_t)(-1) && (q->mb_errno = EILSEQ))

I have package libiconv-1.14_11 installed (though I did not explicitly install it). So merely installing that package is not the fix for this issue despite what has been asserted earlier in this issue.

The ./arch/freebsd11.i386-64/src/lib/libast/ast_standards.h header contains

#define _POSIX_SOURCE   1

As does the same header on macOS and Linux. That keeps /usr/include/sys/errno.h on FreeBSD from defining EILSEQ (but not on macOS or Linux):

#ifndef _POSIX_SOURCE
...
#define EILSEQ          86              /* Illegal byte sequence */
...
#endif /* _POSIX_SOURCE */

This looks like a FreeBSD bug. The EILSEQ symbol is not predicated on any symbol being defined (or not defined) on macOS or Linux. Which makes sense since the C99 standard (and POSIX AFAICT) requires it to be defined. On the other hand, the fish shell builds fine on BSD and it does not define _POSIX_SOURCE via its autotools generated configure script. So there is probably some arcane legacy issue surrounding the semantics of defining _POSIX_SOURCE that the Nmake build tools gets wrong.

Simply adding #include <errno.h> before the #include <ast_standards.h> in src/lib/libast/comp/setlocale.c "fixes" the issue and results in a working ksh binary. Obviously this requires a couple of the other changes already mentioned in this thread such as renaming SF_FLAGS to SFIO_FLAGS and adding #define _STDFILE_DECLARED to the src/lib/libast/features/wchar b/src/lib/libast/features/wchar file.

What I would like to know is why @saper isn't seeing this problem.

My inclination is to remove the explicit definition of the _POSIX_SOURCE symbol. Note that _POSIX_SOURCE has been superseded by _POSIX_C_SOURCE according to Open Group standards. But also note that _POSIX_C_SOURCE is not defined by the fish-shell project (which I contributed to until recently) so it's not clear that we should do so.

krader1961 added a commit that referenced this issue Nov 2, 2017
This was inspired by changes made by Marcin Cieślak (@saper) and
Cy Schubert (@cschuber) but that hadn't been merged upstream. This
includes one additional change I wrote to deal with how FreeBSD uses the
`_POSIX_SOURCE` symbol to hide some things we need (e.g., errno `EILSEQ`).

Fixes #26
@krader1961
Copy link
Contributor

Fixed by commit cbe3543.

siteshwar pushed a commit that referenced this issue Nov 30, 2017
This was inspired by changes made by Marcin Cieślak (@saper) and
Cy Schubert (@cschuber) but that hadn't been merged upstream. This
includes one additional change I wrote to deal with how FreeBSD uses the
`_POSIX_SOURCE` symbol to hide some things we need (e.g., errno `EILSEQ`).

Fixes #26
McDutchie added a commit to ksh93/ksh that referenced this issue Jan 18, 2021
This now makes ksh build on DragonFly BSD.

src/cmd/ksh93/sh/main.c,
src/cmd/ksh93/tests/basic.sh:
- fixargs() doesn't work on DragonFly either
  (re: 9b7c392, 159fb9e, cefe087).

The following are backported from:
att#26 (comment)
att#19

src/lib/libast/comp/setlocale.c:
- Add missing #include <errno.h> since errno is used.

src/lib/libast/features/standards:
- Do not set any standards macros (_POSIX_SOURCE etc) on FreeBSD or
  DragonflyBSD; they disable too much functionality on those.

src/lib/libast/features/wchar:
- Set _STDFILE_DECLARED on DragonFly, too.

src/lib/libast/include/sfio.h,
src/lib/libast/include/sfio_t.h,
src/lib/libast/sfio/_sfopen.c,
src/lib/libast/sfio/sfclrlock.c,
src/lib/libast/sfio/sfhdr.h,
src/lib/libast/sfio/sfnew.c,
src/lib/libast/sfio/sfset.c:
- Rename SF_* macros to SFIO_* to avoid a conflict with system
  headers.

src/lib/libast/string/strexpr.c:
- Rename error() to err() to avoid a conflict.
McDutchie added a commit to ksh93/ksh that referenced this issue Jan 18, 2021
This now makes ksh build on DragonFly BSD.

bin/package, src/cmd/INIT/package.sh:
- DragonFly also needs the -lm hack for LDFLAGS.

src/cmd/ksh93/sh/main.c, src/cmd/ksh93/tests/basic.sh:
- fixargs() doesn't work on DragonFly either
  (re: 9b7c392, 159fb9e, cefe087).

The following are backported from:
att#26 (comment)
att#19

src/lib/libast/comp/setlocale.c:
- Add missing #include <errno.h> since errno is used.

src/lib/libast/features/standards:
- Do not set any standards macros (_POSIX_SOURCE etc) on FreeBSD or
  DragonflyBSD; they disable too much functionality on those.

src/lib/libast/features/wchar:
- Set _STDFILE_DECLARED on DragonFly, too.

src/lib/libast/include/sfio.h, src/lib/libast/include/sfio_t.h,
src/lib/libast/sfio/_sfopen.c, src/lib/libast/sfio/sfclrlock.c,
src/lib/libast/sfio/sfhdr.h, src/lib/libast/sfio/sfnew.c,
src/lib/libast/sfio/sfset.c:
- Rename SF_* macros to SFIO_* to avoid a conflict with system
  headers.

src/lib/libast/string/strexpr.c:
- Rename error() to err() to avoid a conflict.
McDutchie added a commit to ksh93/ksh that referenced this issue Jan 18, 2021
This now makes ksh build on DragonFly BSD.

bin/package, src/cmd/INIT/package.sh:
- DragonFly also needs the -lm hack for LDFLAGS.

src/cmd/ksh93/sh/main.c, src/cmd/ksh93/tests/basic.sh:
- fixargs() doesn't work on DragonFly either
  (re: 9b7c392, 159fb9e, cefe087).

The following are backported from:
att#26 (comment)
att#19

src/lib/libast/comp/setlocale.c:
- Add missing #include <errno.h> since errno is used.

src/lib/libast/features/standards:
- Do not set any standards macros (_POSIX_SOURCE etc) on FreeBSD or
  DragonflyBSD; they disable too much functionality on those.

src/lib/libast/features/wchar:
- Set _STDFILE_DECLARED on DragonFly, too.

src/lib/libast/include/sfio.h, src/lib/libast/include/sfio_t.h,
src/lib/libast/sfio/_sfopen.c, src/lib/libast/sfio/sfclrlock.c,
src/lib/libast/sfio/sfhdr.h, src/lib/libast/sfio/sfnew.c,
src/lib/libast/sfio/sfset.c:
- Rename SF_* macros to SFIO_* to avoid a conflict with system
  headers.

src/lib/libast/string/strexpr.c:
- Rename error() to err() to avoid a conflict.
citrus-it pushed a commit to citrus-it/ast that referenced this issue Apr 15, 2021
Some temp debug code that tests a possible fix for att#26 accidentally
snuck in to a completely unrelated commit. Sorry about that.
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

4 participants