How to make menu link show for certain roles?
In D8 this is a menu link class, which you can add to a menu in *.links.menu.yml:

mymodule.links.menu.yml

mymodule.logout:
  weight: 10
  menu_name: mymenu
  class: Drupal\user\Plugin\Menu\LoginLogoutMenuLink


This class shows Log in or Log out for user roles authenticated or not:

  public function getTitle() {
    if ($this-&gt;currentUser-&gt;isAuthenticated()) {
      return $this-&gt;t('Log out');
    }
    else {
      return $this-&gt;t('Log in');
    }
  }


and links it to the corresponding route:

  public function getRouteName() {
    if ($this-&gt;currentUser-&gt;isAuthenticated()) {
      return 'user.logout';
    }
    else {
      return 'user.login';
    }
  }