# Swipl is now on msys2 - Reply 1

**URL:** https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163
**Category:** General
**Created:** [March 24, 2022, 10:26am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163 "2022-03-24T10:26:44Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)
#### Post date: [March 24, 2022, 10:26am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/1 "2022-03-24T10:26:44Z")

</div>

> [@Swipl is now on msys2](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2/5162/1):
>
> `member(1, X).`

Great! But … ☹ … where has the prompt gone?

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 24, 2022, 10:42am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/2 "2022-03-24T10:42:55Z")

</div>

There isn’t any readline support either, so still some work to do. In the meantime, use „start swipl“ instead of „swipl“, then a new command window is opened and you have a prompt.

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 24, 2022, 11:12am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/3 "2022-03-24T11:12:48Z")

</div>

Below are the warnings in current swipl-devel if I compile under current msys2. I’ll check them one by one, though I fear my insight is too limited to be of great use.

[Edit: my sources were not up to date with swipl-devel. I’ll send an update in a separate response.]

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 24, 2022, 11:59am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/4 "2022-03-24T11:59:59Z")

</div>

Updated list of warnings, sorry for the confusion.

```prolog
[197/953] Building C object src/CMakeFiles/swiplobjs.dir/pl-alloc.c.obj
In function 'tmp_realloc',
    inlined from 'stack_realloc' at C:/msys64/home/c7201178/swipl-devel/src/pl-alloc.c:1612:15:
C:/msys64/home/c7201178/swipl-devel/src/pl-alloc.c:1574:15: warning: 'realloc' called on a pointer to an unallocated object '18446744073709551608' [-Wfree-nonheap-object]
 1574 | if ( (mem = realloc(sp, size+sizeof(size_t))) )
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[239/953] Building C object packages/clib/CMakeFiles/plugin_crypt.dir/bsd-crypt.c.obj
In function 'init_des',
    inlined from 'des_setkey' at C:/msys64/home/c7201178/swipl-devel/packages/clib/bsd-crypt.c:622:3,
    inlined from 'crypt' at C:/msys64/home/c7201178/swipl-devel/packages/clib/bsd-crypt.c:523:6:
C:/msys64/home/c7201178/swipl-devel/packages/clib/bsd-crypt.c:848:9: warning: 'init_perm.constprop' accessing 2048 bytes in a region of size 1024 [-Wstringop-overflow=]
  848 | init_perm(IE3264, perm, 4, 8);
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/c7201178/swipl-devel/packages/clib/bsd-crypt.c: In function 'crypt':
C:/msys64/home/c7201178/swipl-devel/packages/clib/bsd-crypt.c:848:9: note: referencing argument 1 of type 'C_block (*)[16]'
C:/msys64/home/c7201178/swipl-devel/packages/clib/bsd-crypt.c:910:1: note: in a call to function 'init_perm.constprop'
  910 | init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS], const unsigned char p[64],
      | ^ ~~~~~~~~

```

---

<div class="post-metadata">

### Author: ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)
#### Post date: [March 24, 2022, 12:20pm UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/5 "2022-03-24T12:20:53Z")

</div>

As for the realloc warning I don’t really see the problem. But then, most systems will use the memory mapping based implementation and I think MSYS can do that as well.

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 24, 2022, 2:12pm UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/6 "2022-03-24T14:12:17Z")

</div>

Actually, it can’t. It’s POSIX, not Windows. Anyway, I could make the realloc warning disappear, see the PR.

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 24, 2022, 3:19pm UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/7 "2022-03-24T15:19:31Z")

</div>

I made a second PR to make the warning in bsd-crypt.c disappear. Hope it makes sense.

---

<div class="post-metadata">

### Author: ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)
#### Post date: [March 24, 2022, 3:32pm UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/8 "2022-03-24T15:32:51Z")

</div>

> [@mgondan1](#):
>
> Actually, it can’t. It’s POSIX, not Windows

I don’t think that is true. MSYS2 says:

> **MSYS2** is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software

They use the MinGW GCC fork and provide the whole Windows API. AFAIK, the C runtime library that comes with it does have a couple more POSIX like functions.

That said, the SWI-Prolog code provides a set of functions that provide malloc() compatible functionality but uses memory mapping when possible such that the memory is really returned to the OS. That is used for the Prolog stacks and some other potentially large areas such as the buffer used to store findall/3 results. This has only been implemented to use mmap() though, not Windows VirtualAlloc().

> [@mgondan1](#):
>
> I made a second PR

Thanks. Did you push it? I do not see it.

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 24, 2022, 3:46pm UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/9 "2022-03-24T15:46:52Z")

</div>

Yes, indeed, VirtualAlloc would be needed instead of mmap.

I’ll check where the other PR got stuck.

---

<div class="post-metadata">

### Author: ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)
#### Post date: [March 25, 2022, 8:14am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/10 "2022-03-25T08:14:23Z")

</div>

Regarding the other warning (init\_perm.constprop’ accessing 2048 bytes in a region of size 1024).

I can partially reproduce it on Linux, since bsd-crypt.c also includes a main for stand-alone use:

mkdir bsdcrypt  
cd bsdcrypt  
cp …/swipl-devel/packages/clib/bsd-crypt.c .  
gcc -DMAIN bsd-crypt.c

```prolog
matthias@DESKTOP-A2T8IFC:~/crypt$ gcc -DMAIN bsd-crypt.c
bsd-crypt.c: In function ‘init_des’:
bsd-crypt.c:848:9: warning: ‘init_perm’ accessing 2048 bytes in a region of size 1024 [-Wstringop-overflow=]
  848 | init_perm(IE3264, perm, 4, 8);
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bsd-crypt.c:848:9: note: referencing argument 1 of type ‘C_block (*)[16]’
bsd-crypt.c:910:1: note: in a call to function ‘init_perm’
  910 | init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS], const unsigned char p[64],
      | ^ ~~~~~~~~

```

I guess init\_perm is “safe” in the sense that it is never invoked with pathological parameter settings, but the whole thing feels a bit awkward, see below for a simplified analogy.

```prolog
int fun1(char buf[10])
{ for(int i=0; i<5; i++)
    buf[i]++;
  return 0;
}

int main()
{ char buf1[5];
  return fun1(buf1);
}

```

I’ll submit another PR (bit prettier than last time) for your consideration.

---

<div class="post-metadata">

### Author: ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)
#### Post date: [March 25, 2022, 8:57am UTC](https://swi-prolog.discourse.group/t/swipl-is-now-on-msys2-reply-1/5163/11 "2022-03-25T08:57:37Z")

</div>

I see. Just using `int fun1(char *buf)` should fix that. It makes not much sense to declare the size in the function and than call it with various sizes anyway.
